fix-unread-counter

This commit is contained in:
tonyrewin 2022-11-16 09:47:08 +03:00
parent 606655ee2c
commit d78ba7ed3e

View File

@ -18,13 +18,14 @@ async def get_unread_counter(chat_id: str, user_slug: str):
async def get_total_unread_counter(user_slug: str): async def get_total_unread_counter(user_slug: str):
chats = await redis.execute("GET", f"chats_by_user/{user_slug}") chats = await redis.execute("GET", f"chats_by_user/{user_slug}")
if not chats: if not chats:
chats = []
return 0 return 0
else:
chats = json.loads(chats) chats = json.loads(chats)
unread = 0 unread = 0
for chat_id in chats: for chat_id in chats:
n = await get_unread_counter(chat_id, user_slug) n = await get_unread_counter(chat_id, user_slug)
unread += n unread += n
return unread return unread