diff --git a/README.md b/README.md index 9ea1db5..81f542c 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ pnpm test - no user authentication - Client Websockets should be more robust, i.e. reconnecting - Client state does not persist on refresh -- Client messages are rendered all at once, a virtual list would be better after a certain amount of messages +- Performance: when sending a very large amount of messages, like 100000, the browser will freeze. This is not due to bad rendering per se, but the websocket message ingestion. Fixing this would be quite easy with a server-sided message debounce. - Test coverage very limited: only a single component is tested - Keyboard navigation and focus management could be improved - Entire deployment process is missing, i.e. Dockerfiles, CI/CD, reverse proxy diff --git a/client/src/components/ChatMessage/ChatMessageDisplay.tsx b/client/src/components/ChatMessage/ChatMessageDisplay.tsx index b2ff29e..c926c80 100644 --- a/client/src/components/ChatMessage/ChatMessageDisplay.tsx +++ b/client/src/components/ChatMessage/ChatMessageDisplay.tsx @@ -39,7 +39,7 @@ function ChatMessageDisplay({ return (
-
+
-

Simple Chat

+

Simple Chat

-
+
{children}
diff --git a/client/src/components/MessageDisplay.tsx b/client/src/components/MessageDisplay.tsx index c426cc4..f2ff888 100644 --- a/client/src/components/MessageDisplay.tsx +++ b/client/src/components/MessageDisplay.tsx @@ -37,9 +37,9 @@ function MessageDisplay({ sendMessage }: MessageDisplayProps) { sendMessage(editMessage); }; - // Scroll to bottom when messages change useEffect(() => { if (listRef.current) { + // Scroll to bottom when messages change listRef.current.scrollToItem(state.messages.length - 1); } }, [state.messages]); @@ -83,7 +83,7 @@ function MessageDisplay({ sendMessage }: MessageDisplayProps) { }; return ( -
+
{({ height, width }) => ( Room ID: {props.roomId} {state.currentUser && ( - User: {state.currentUser?.name} + + User: {state.currentUser?.name} + )}