diff --git a/.gitignore b/.gitignore
index e86939e..24272d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@ node_modules
pnpm-lock.yaml
.todo
.env
-messages.json
\ No newline at end of file
+messages.json
+api/*.js
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..99a9dfa
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,29 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+## [Unreleased]
+
+### Added
+- dev dependency `cfx` in order to add the `copy-static` script in `package.json`
+- a popup file in the chrome extension to permit the user to directly open the react page. Now the link it's hardcoded
+
+
+
+
+- add a retry system to connect to the chat in `index.ts` in order to manage anomalies in case the component is loaded faster than the page
+- add a `sessionId` generated each time there is a "reload" of the page so the webapp inserts a divider to let the streamer knows where the
+chat session begins
+- add `ChatDivider` component to let the user know when the chat has been reloaded
+- add a footer on the chat that indicates if the autoreload is `on` or `off`
+- add a badge on the extension in order to detect if it is connected to a chat
+
+
+
+
+
+### Changed
+- `build` script in order to build the Chrome extension and copy all the relevant files in the ui folder
+
+### Notes
+- the ChatDivider and the footer needs a graphical review but they are both working
diff --git a/README.md b/README.md
index 6e130fc..67c4b14 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,9 @@ By offering a consistent, user-friendly interface, Chat Fusion makes managing an
```bash
pnpm i
pnpm build # to build the chrome extension
+
+cd chat
+pnpm i # to install the dependencies for the chat
```
You have to run the client (React) code and the API (fastify) separetly.
diff --git a/api/server.ts b/api/server.ts
index 665d128..8ab542a 100644
--- a/api/server.ts
+++ b/api/server.ts
@@ -7,6 +7,7 @@ import cors from "@fastify/cors";
import fs from "fs";
export interface IMessage {
+ sessionId: string;
id: string;
platform: string;
content: string;
@@ -28,12 +29,25 @@ server.post(
"/api/messages",
async (request: FastifyRequest, reply: FastifyReply) => {
const message = request.body as IMessage;
+ if (messages.length > 0 && messages[messages.length - 1].sessionId !== message.sessionId) {
+ // new session, add system message
+ messages.push({
+ sessionId: message.sessionId,
+ id: Math.random().toString(36).substr(2, 9),
+ platform: message.platform,
+ content: "Chat reload",
+ author: "System",
+ emojis: [],
+ badge: "",
+ });
+ }
messages.push(message);
reply.code(201).send();
}
);
server.get("/api/messages", async (_: FastifyRequest, reply: FastifyReply) => {
+
reply.send(messages);
});
diff --git a/assets/images/badge.png b/assets/images/badge.png
new file mode 100644
index 0000000..8a51ec6
Binary files /dev/null and b/assets/images/badge.png differ
diff --git a/assets/images/popup.png b/assets/images/popup.png
new file mode 100644
index 0000000..45fe7b5
Binary files /dev/null and b/assets/images/popup.png differ
diff --git a/chat/package.json b/chat/package.json
index 606adbd..2d15f50 100644
--- a/chat/package.json
+++ b/chat/package.json
@@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
- "dev": "VITE_STYLE_MODE=true vite",
+ "dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
diff --git a/chat/src/Components/Chat/Chat.tsx b/chat/src/Components/Chat/Chat.tsx
index 3e144b8..da8484d 100644
--- a/chat/src/Components/Chat/Chat.tsx
+++ b/chat/src/Components/Chat/Chat.tsx
@@ -1,7 +1,8 @@
-import { useEffect, useRef, FC } from "react";
+import { useEffect, useRef, FC, useState } from "react";
import { IMessage } from "../../types";
import { Message } from "../Message";
import classNames from "classnames";
+import { ChatDivider } from "../ChatDivider";
export const Chat: FC<{
messages: IMessage[];
@@ -9,7 +10,7 @@ export const Chat: FC<{
setFocusedMessage: (message: IMessage | null) => void;
}> = ({ messages, focusedMessage, setFocusedMessage }) => {
const messagesEndRef = useRef(null);
-
+ const [autoScroll, setAutoScroll] = useState(true);
const handleFocusMessage = (message: IMessage) => {
setFocusedMessage(message.id === focusedMessage?.id ? null : message);
};
@@ -20,28 +21,47 @@ export const Chat: FC<{
}
};
- useEffect(() => {
- scrollToBottom();
- }, [messages]);
-
- return (
-