From 65236df78ab7fc8df3e436bb8d8b5948cc5a8f0d Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 29 Nov 2022 16:09:44 -0600 Subject: [PATCH] don't read multiple times etc --- files/routes/wrappers.py | 8 ++++---- files/templates/mobile_navigation_bar.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/routes/wrappers.py b/files/routes/wrappers.py index 60f7f3eb4..6a01a1fbc 100644 --- a/files/routes/wrappers.py +++ b/files/routes/wrappers.py @@ -45,11 +45,11 @@ def calc_users(v): g.loggedout_counter = len(loggedout) return '' -def calc_chat_users(): - if g.is_api_or_xhr: +def calc_chat_users(v:Optional[User]): + if v and g.is_api_or_xhr: g.loggedin_chat = 0 - else: - g.loggedin_chat = cache.get(CHAT_ONLINE_CACHE_KEY, 0) + elif not hasattr(g, 'loggedin_chat'): + g.loggedin_chat = cache.get(CHAT_ONLINE_CACHE_KEY) or 0 return '' def get_logged_in_user(): diff --git a/files/templates/mobile_navigation_bar.html b/files/templates/mobile_navigation_bar.html index 4fb7f2a1c..218d07c5c 100644 --- a/files/templates/mobile_navigation_bar.html +++ b/files/templates/mobile_navigation_bar.html @@ -1,4 +1,4 @@ -{{calc_chat_users()}} +{{calc_chat_users(v)}}