diff --git a/src/backend/backend.py b/src/backend/backend.py index d5e3409a..fea589a2 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -242,6 +242,26 @@ class Backend: return await client.download(server_name, media_id) + async def room_read(self, room_id: str) -> None: + """Mark all messages in a room as read for all accounts part of it + + Currently, this doesn't handle sending a read receipt to the server, + only cleaning up any unread indicators. + """ + + for client in self.clients.values(): + client.open_room = room_id + + if not client.first_sync_done.is_set(): + continue + + room = self.models[client.user_id, "rooms"].get(room_id) + + if room: + room.mentions = 0 + room.unreads = 0 + + # General functions async def get_config_dir(self) -> Path: diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index a46c98ab..cadb9831 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -832,19 +832,6 @@ class MatrixClient(nio.AsyncClient): await super().room_forget(room_id) - async def room_read(self, room_id: str) -> None: - """Mark all messages in a room as read - - Currently, this doesn't handle sending a read receipt to the server, - only cleaning up any unread indicators. - """ - - self.open_room = room_id - if self.first_sync_done.is_set(): - room = self.models[self.user_id, "rooms"][room_id] - room.mentions = 0 - room.unreads = 0 - async def room_mass_invite( self, room_id: str, *user_ids: str, ) -> Tuple[List[str], List[Tuple[str, Exception]]]: diff --git a/src/gui/PageLoader.qml b/src/gui/PageLoader.qml index 6fafe656..1d87962d 100644 --- a/src/gui/PageLoader.qml +++ b/src/gui/PageLoader.qml @@ -61,7 +61,7 @@ HLoader { function showRoom(userId, roomId) { _show("Pages/Chat/Chat.qml", {userId, roomId}) - py.callClientCoro(userId, "room_read", [roomId], () => {}) + py.callCoro("room_read", [roomId]) window.uiState.page = "Pages/Chat/Chat.qml" window.uiState.pageProperties = {userId, roomId}