Use new nio server-backed room unread counts

This commit is contained in:
miruka 2020-05-31 19:06:25 -04:00
parent 7b5aa8ffe1
commit dce3328037
2 changed files with 6 additions and 19 deletions

View File

@ -15,6 +15,9 @@
## Issues ## Issues
- Don't send typing notification when switching to a room where the composer
has loaded text
- SSL error on python 3.7 - SSL error on python 3.7
- Jumping between accounts (clicking in account bar or alt+(Shift+)N) is - Jumping between accounts (clicking in account bar or alt+(Shift+)N) is

View File

@ -1259,13 +1259,9 @@ class MatrixClient(nio.AsyncClient):
registered = None registered = None
last_event_date = datetime.fromtimestamp(0) last_event_date = datetime.fromtimestamp(0)
typing_members = [] typing_members = []
mentions = 0
unreads = 0
else: else:
last_event_date = registered.last_event_date last_event_date = registered.last_event_date
typing_members = registered.typing_members typing_members = registered.typing_members
mentions = registered.mentions
unreads = registered.unreads
room_item = Room( room_item = Room(
id = room.room_id, id = room.room_id,
@ -1301,8 +1297,9 @@ class MatrixClient(nio.AsyncClient):
can_set_guest_access = can_send_state("m.room.guest_access"), can_set_guest_access = can_send_state("m.room.guest_access"),
last_event_date = last_event_date, 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 self.models[self.user_id, "rooms"][room.room_id] = room_item
@ -1472,16 +1469,3 @@ class MatrixClient(nio.AsyncClient):
return return
AlertRequested() 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