diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 3f12dac3c0..84c590c639 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -1,4 +1,4 @@ -from files.__main__ import app +from files.__main__ import app, cache from .get import * from os import listdir, environ from .const import * @@ -58,4 +58,4 @@ def inject_constants(): "LOTTERY_ENABLED": LOTTERY_ENABLED, "GUMROAD_LINK": GUMROAD_LINK, "DEFAULT_THEME": DEFAULT_THEME, "DESCRIPTION": DESCRIPTION, "has_sidebar": has_sidebar, "has_logo": has_logo, "has_app": has_app, - "FP": FP, "NOTIF_MODACTION_JL_MIN": NOTIF_MODACTION_JL_MIN} + "FP": FP, "NOTIF_MODACTION_JL_MIN": NOTIF_MODACTION_JL_MIN, "cache": cache, "ONLINE_STR": f'{SITE}_online'} diff --git a/files/routes/chat.py b/files/routes/chat.py index cc2e98c356..7ed3ba3710 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -91,6 +91,9 @@ def connect(v): if v.username not in online: online.append(v.username) emit("online", online, broadcast=True) + online = cache.get(f'{SITE}_online') or 0 + online += 1 + cache.set(f'{SITE}_online', online) emit('typing', typing) return '', 204 @@ -101,6 +104,9 @@ def disconnect(v): if v.username in online: online.remove(v.username) emit("online", online, broadcast=True) + online = cache.get(f'{SITE}_online') or 1 + online -= 1 + cache.set(f'{SITE}_online', online) if v.username in typing: typing.remove(v.username) emit('typing', typing, broadcast=True) diff --git a/files/templates/header.html b/files/templates/header.html index 660512e8b0..a6aca4afdf 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -166,7 +166,12 @@ {% if FEATURES['CHAT'] -%}