From edb68dc0dd7fb80b19ce3d863b244812db5f2f2c Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Wed, 16 Nov 2022 09:48:32 +0300 Subject: [PATCH] unread-fix --- resolvers/inbox/load.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/resolvers/inbox/load.py b/resolvers/inbox/load.py index 3e166402..1014db0f 100644 --- a/resolvers/inbox/load.py +++ b/resolvers/inbox/load.py @@ -17,16 +17,12 @@ async def get_unread_counter(chat_id: str, user_slug: str): async def get_total_unread_counter(user_slug: str): chats = await redis.execute("GET", f"chats_by_user/{user_slug}") - if not chats: - chats = [] - return 0 - else: + unread = 0 + if chats: chats = json.loads(chats) - unread = 0 for chat_id in chats: n = await get_unread_counter(chat_id, user_slug) unread += n - return unread