Add a batch set_fields method to Model

This commit is contained in:
miruka
2020-07-01 12:00:50 -04:00
parent 5476e00b9b
commit 4752abf6e5
4 changed files with 75 additions and 43 deletions

View File

@@ -300,14 +300,15 @@ class Backend:
"""
async def update(client: MatrixClient) -> None:
room = self.models[client.user_id, "rooms"].get(room_id)
local = room.local_unreads or room.local_highlights
room = self.models[client.user_id, "rooms"].get(room_id)
if room and (room.unreads or room.highlights or local):
room.unreads = 0
room.highlights = 0
room.local_unreads = False
room.local_highlights = False
if room:
room.set_fields(
unreads = 0,
highlights = 0,
local_unreads = False,
local_highlights = False,
)
await client.update_account_unread_counts()
await client.update_receipt_marker(room_id, event_id)