diff --git a/TODO.md b/TODO.md index b52b1ed6..fd3f1a1c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,9 @@ # TODO -- add unread counts on accounts - add account number binds - rename goto*account → scrollto*account +- fix python error - fix back/front buttons in small window - fix message delegate too tall - fix left rooms opacity diff --git a/src/backend/backend.py b/src/backend/backend.py index fea589a2..345273af 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -249,15 +249,19 @@ class Backend: only cleaning up any unread indicators. """ - for client in self.clients.values(): + for user_id, client in self.clients.items(): client.open_room = room_id if not client.first_sync_done.is_set(): continue - room = self.models[client.user_id, "rooms"].get(room_id) + room = self.models[user_id, "rooms"].get(room_id) if room: + account = self.models["accounts"][user_id] + account.total_unread -= room.unreads + account.total_mentions -= room.mentions + room.mentions = 0 room.unreads = 0 diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 0c24b092..be238536 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1374,10 +1374,14 @@ class MatrixClient(nio.AsyncClient): AlertRequested() if self.open_room != room.room_id: - room = self.models[self.user_id, "rooms"][room.room_id] - room.unreads += 1 + 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): - room.mentions += 1 + account.total_mentions += 1 + room.mentions += 1 diff --git a/src/backend/models/items.py b/src/backend/models/items.py index 6f25b597..7d127702 100644 --- a/src/backend/models/items.py +++ b/src/backend/models/items.py @@ -38,6 +38,8 @@ class Account(ModelItem): max_upload_size: int = 0 profile_updated: datetime = ZeroDate first_sync_done: bool = False + total_unread: int = 0 + total_mentions: int = 0 def __lt__(self, other: "Account") -> bool: """Sort by user ID.""" diff --git a/src/gui/MainPane/AccountsBar.qml b/src/gui/MainPane/AccountsBar.qml index a96f8513..c44a025c 100644 --- a/src/gui/MainPane/AccountsBar.qml +++ b/src/gui/MainPane/AccountsBar.qml @@ -79,6 +79,16 @@ HColumnLayout { radius: theme.accountsBar.accountList.account.avatarRadius } + + MessageIndicator { + anchors.right: parent.right + anchors.bottom: parent.bottom + + indicatorTheme: + theme.accountView.roomList.room.unreadIndicator + unreads: model.total_unread + mentions: model.total_mentions + } } onLeftClicked: roomList.goToAccount(model.id) diff --git a/src/gui/MainPane/MessageIndicator.qml b/src/gui/MainPane/MessageIndicator.qml index dbe52c1c..6e3b3b10 100644 --- a/src/gui/MainPane/MessageIndicator.qml +++ b/src/gui/MainPane/MessageIndicator.qml @@ -30,6 +30,5 @@ HLabel { property int mentions: 0 - Behavior on scale { HNumberAnimation {} } }