From 41497958b6234a25bbf60d956615550765e49ad9 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Mon, 4 Sep 2023 15:15:36 -0500 Subject: [PATCH] Clean up a few minor code quality issues in the chat system. --- chat/src/hooks/useChat.tsx | 7 ------- files/routes/chat.py | 5 ++--- readme.md | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/chat/src/hooks/useChat.tsx b/chat/src/hooks/useChat.tsx index aa840262b..d8ea14a2b 100644 --- a/chat/src/hooks/useChat.tsx +++ b/chat/src/hooks/useChat.tsx @@ -68,10 +68,7 @@ export function ChatProvider({ children }: PropsWithChildren) { const setMessagesAndRead = useCallback((messages: IChatMessage[]) => { setMessages(messages); - console.log("TSRM begin"); - console.log(messages); trySendReadMessage(messages); - console.log("TSRM end") }, []); const addMessage = useCallback((message: IChatMessage) => { @@ -151,7 +148,6 @@ export function ChatProvider({ children }: PropsWithChildren) { const [lastMaxTime, setLastMaxTime] = useState(null); const trySendReadMessage = useCallback((messages: IChatMessage[]) => { if (messages.length === 0) { - console.log("Early abort"); return; // Exit if the messages array is empty } @@ -160,10 +156,7 @@ export function ChatProvider({ children }: PropsWithChildren) { if (maxTime !== lastMaxTime) { // Only emit if there's a new maxTime setLastMaxTime(maxTime); // Update the stored maxTime socket.current?.emit(ChatHandlers.READ, maxTime); - console.log("Smaxy"); } - - console.log("duvo"); }, [lastMaxTime]); diff --git a/files/routes/chat.py b/files/routes/chat.py index 2f047da52..3851dde9b 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -150,7 +150,7 @@ def speak(data, v): @socketio.on('connect') @chat_is_allowed() -def onConnect(v): +def on_connect(v): if v.username not in online: online.append(v.username) @@ -163,7 +163,7 @@ def onConnect(v): @socketio.on('disconnect') @chat_is_allowed() -def onDisconnect(v): +def on_disconnect(v): if v.username in online: online.remove(v.username) @@ -267,4 +267,3 @@ def reset_everything_seriously(_): # Commit the changes to the database g.db.commit() - diff --git a/readme.md b/readme.md index e05daca8d..1009735be 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,7 @@ The first time you do this, it will take a while. It'll be (much) faster next ti Most code edits will be reflected (almost) immediately. If you make any setup changes or database changes, you'll need to ctrl-C the docker-compose status log and run `docker-compose up --build` again. -Chat-related code edits will take a minute to update (if it's in Python) or won't be reflected automatically at all (if it's in Flask). Improvements welcome! But almost nobody touches these systems, so it hasn't been a priority. +Chat-related code edits will take a minute to update (if it's in Python) or won't be reflected automatically at all (if it's in React). Improvements welcome! But almost nobody touches these systems, so it hasn't been a priority. # Run the E2E tests: