Mark rooms as read on all our accounts

This commit is contained in:
miruka 2020-04-16 13:24:49 -04:00
parent 568d4fddce
commit 0a1834b763
3 changed files with 21 additions and 14 deletions

View File

@ -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:

View File

@ -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]]]:

View File

@ -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}