From dce3328037af44cfa9663ab8ed1e08df73dd27ac Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 31 May 2020 19:06:25 -0400 Subject: [PATCH] Use new nio server-backed room unread counts --- TODO.md | 3 +++ src/backend/matrix_client.py | 22 +++------------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/TODO.md b/TODO.md index 8dfd7cf2..6c0ae774 100644 --- a/TODO.md +++ b/TODO.md @@ -15,6 +15,9 @@ ## Issues +- Don't send typing notification when switching to a room where the composer + has loaded text + - SSL error on python 3.7 - Jumping between accounts (clicking in account bar or alt+(Shift+)N) is diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index a57d2e68..f382f685 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1259,13 +1259,9 @@ class MatrixClient(nio.AsyncClient): registered = None last_event_date = datetime.fromtimestamp(0) typing_members = [] - mentions = 0 - unreads = 0 else: last_event_date = registered.last_event_date typing_members = registered.typing_members - mentions = registered.mentions - unreads = registered.unreads room_item = Room( id = room.room_id, @@ -1301,8 +1297,9 @@ class MatrixClient(nio.AsyncClient): can_set_guest_access = can_send_state("m.room.guest_access"), last_event_date = last_event_date, - mentions = mentions, - unreads = unreads, + + mentions = room.unread_highlights, + unreads = room.unread_notifications, ) self.models[self.user_id, "rooms"][room.room_id] = room_item @@ -1472,16 +1469,3 @@ class MatrixClient(nio.AsyncClient): return AlertRequested() - - if self.open_room != room.room_id: - account = self.models["accounts"][self.user_id] - room = self.models[self.user_id, "rooms"][room.room_id] - - account.total_unread += 1 - room.unreads += 1 - - content = fields.get("content", "") - - if HTML.user_id_link_in_html(content, self.user_id): - account.total_mentions += 1 - room.mentions += 1