Clean up a few minor code quality issues in the chat system.

This commit is contained in:
Ben Rog-Wilhelm 2023-09-04 15:15:36 -05:00
parent ae58ca89eb
commit 41497958b6
3 changed files with 3 additions and 11 deletions

View file

@ -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<number | null>(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]);

View file

@ -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()

View file

@ -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: