Add account total unread/mentions indicator
This commit is contained in:
parent
9ebd8644c8
commit
9f7d30f248
2
TODO.md
2
TODO.md
|
@ -1,9 +1,9 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- add unread counts on accounts
|
|
||||||
- add account number binds
|
- add account number binds
|
||||||
- rename goto*account → scrollto*account
|
- rename goto*account → scrollto*account
|
||||||
|
|
||||||
|
- fix python error
|
||||||
- fix back/front buttons in small window
|
- fix back/front buttons in small window
|
||||||
- fix message delegate too tall
|
- fix message delegate too tall
|
||||||
- fix left rooms opacity
|
- fix left rooms opacity
|
||||||
|
|
|
@ -249,15 +249,19 @@ class Backend:
|
||||||
only cleaning up any unread indicators.
|
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
|
client.open_room = room_id
|
||||||
|
|
||||||
if not client.first_sync_done.is_set():
|
if not client.first_sync_done.is_set():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
room = self.models[client.user_id, "rooms"].get(room_id)
|
room = self.models[user_id, "rooms"].get(room_id)
|
||||||
|
|
||||||
if room:
|
if room:
|
||||||
|
account = self.models["accounts"][user_id]
|
||||||
|
account.total_unread -= room.unreads
|
||||||
|
account.total_mentions -= room.mentions
|
||||||
|
|
||||||
room.mentions = 0
|
room.mentions = 0
|
||||||
room.unreads = 0
|
room.unreads = 0
|
||||||
|
|
||||||
|
|
|
@ -1374,10 +1374,14 @@ class MatrixClient(nio.AsyncClient):
|
||||||
AlertRequested()
|
AlertRequested()
|
||||||
|
|
||||||
if self.open_room != room.room_id:
|
if self.open_room != room.room_id:
|
||||||
|
account = self.models["accounts"][self.user_id]
|
||||||
room = self.models[self.user_id, "rooms"][room.room_id]
|
room = self.models[self.user_id, "rooms"][room.room_id]
|
||||||
|
|
||||||
|
account.total_unread += 1
|
||||||
room.unreads += 1
|
room.unreads += 1
|
||||||
|
|
||||||
content = fields.get("content", "")
|
content = fields.get("content", "")
|
||||||
|
|
||||||
if HTML.user_id_link_in_html(content, self.user_id):
|
if HTML.user_id_link_in_html(content, self.user_id):
|
||||||
|
account.total_mentions += 1
|
||||||
room.mentions += 1
|
room.mentions += 1
|
||||||
|
|
|
@ -38,6 +38,8 @@ class Account(ModelItem):
|
||||||
max_upload_size: int = 0
|
max_upload_size: int = 0
|
||||||
profile_updated: datetime = ZeroDate
|
profile_updated: datetime = ZeroDate
|
||||||
first_sync_done: bool = False
|
first_sync_done: bool = False
|
||||||
|
total_unread: int = 0
|
||||||
|
total_mentions: int = 0
|
||||||
|
|
||||||
def __lt__(self, other: "Account") -> bool:
|
def __lt__(self, other: "Account") -> bool:
|
||||||
"""Sort by user ID."""
|
"""Sort by user ID."""
|
||||||
|
|
|
@ -79,6 +79,16 @@ HColumnLayout {
|
||||||
|
|
||||||
radius: theme.accountsBar.accountList.account.avatarRadius
|
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)
|
onLeftClicked: roomList.goToAccount(model.id)
|
||||||
|
|
|
@ -30,6 +30,5 @@ HLabel {
|
||||||
property int mentions: 0
|
property int mentions: 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Behavior on scale { HNumberAnimation {} }
|
Behavior on scale { HNumberAnimation {} }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user