diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index 848436453..a977ac3cc 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -10,7 +10,7 @@ from files.helpers.const import * from files.helpers.settings import get_settings from files.helpers.sorting_and_time import make_age_string from files.routes.routehelpers import get_formkey -from files.routes.wrappers import calc_users +from files.routes.wrappers import calc_users, calc_chat_users from files.__main__ import app, cache @app.template_filter("formkey") @@ -56,7 +56,7 @@ def inject_constants(): "BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD, "KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK, "approved_embed_hosts":approved_embed_hosts, - "site_settings":get_settings(), "EMAIL":EMAIL, "calc_users":calc_users, + "site_settings":get_settings(), "EMAIL":EMAIL, "calc_users":calc_users, "calc_chat_users":calc_chat_users, "max": max, "min": min, "user_can_see":User.can_see, "TELEGRAM_LINK":TELEGRAM_LINK, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN, "TRUESCORE_DONATE_MINIMUM":TRUESCORE_DONATE_MINIMUM, diff --git a/files/routes/wrappers.py b/files/routes/wrappers.py index 27b79436b..60f7f3eb4 100644 --- a/files/routes/wrappers.py +++ b/files/routes/wrappers.py @@ -43,7 +43,13 @@ def calc_users(v): g.loggedin_counter = len(loggedin) g.loggedout_counter = len(loggedout) - g.loggedin_chat = cache.get(CHAT_ONLINE_CACHE_KEY) + return '' + +def calc_chat_users(): + if g.is_api_or_xhr: + g.loggedin_chat = 0 + else: + g.loggedin_chat = cache.get(CHAT_ONLINE_CACHE_KEY, 0) return '' def get_logged_in_user(): diff --git a/files/templates/mobile_navigation_bar.html b/files/templates/mobile_navigation_bar.html index 141ce3967..4fb7f2a1c 100644 --- a/files/templates/mobile_navigation_bar.html +++ b/files/templates/mobile_navigation_bar.html @@ -1,3 +1,4 @@ +{{calc_chat_users()}}