From dd6f86ce31d2ad61ce7e4338caa6cd46ad086e3b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 13 Aug 2022 12:05:27 +0200 Subject: [PATCH] fix online count --- files/routes/chat.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/files/routes/chat.py b/files/routes/chat.py index 46665cdcf..ded184fcb 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -91,9 +91,7 @@ def connect(v): if v.username not in online: online.append(v.username) emit("online", online, broadcast=True) - online_count = cache.get(f'{SITE}_online') or 0 - online_count += 1 - cache.set(f'{SITE}_online', online_count) + cache.set(f'{SITE}_online', len(online)) emit('typing', typing) return '', 204 @@ -104,9 +102,7 @@ def disconnect(v): if v.username in online: online.remove(v.username) emit("online", online, broadcast=True) - online_count = cache.get(f'{SITE}_online') or 1 - online_count -= 1 - cache.set(f'{SITE}_online', online_count) + cache.set(f'{SITE}_online', len(online)) if v.username in typing: typing.remove(v.username) emit('typing', typing, broadcast=True)