diff --git a/src/backend/backend.py b/src/backend/backend.py index b9fa23f3..de7b0757 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -379,10 +379,9 @@ class Backend: if room: room.set_fields( - unreads = 0, - highlights = 0, - local_unreads = False, - local_highlights = False, + unreads = 0, + highlights = 0, + local_unreads = False, ) await client.update_account_unread_counts() diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 8c0c70f7..1223007b 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1833,10 +1833,9 @@ class MatrixClient(nio.AsyncClient): async def update_account_unread_counts(self) -> None: """Recalculate total unread notifications/highlights for our account""" - unreads = 0 - highlights = 0 - local_unreads = False - local_highlights = False + unreads = 0 + highlights = 0 + local_unreads = False for room in self.models[self.user_id, "rooms"].values(): unreads += room.unreads @@ -1845,15 +1844,11 @@ class MatrixClient(nio.AsyncClient): if room.local_unreads: local_unreads = True - if room.local_highlights: - local_highlights = True - account = self.models["accounts"][self.user_id] account.set_fields( total_unread = unreads, total_highlights = highlights, local_unreads = local_unreads, - local_highlights = local_highlights, ) @@ -1903,7 +1898,6 @@ class MatrixClient(nio.AsyncClient): last_event_date = datetime.fromtimestamp(0) typing_members = [] local_unreads = False - local_highlights = False update_account_unread_counts = True unverified_devices = ( False @@ -1914,7 +1908,6 @@ class MatrixClient(nio.AsyncClient): last_event_date = registered.last_event_date typing_members = registered.typing_members local_unreads = registered.local_unreads - local_highlights = registered.local_highlights update_account_unread_counts = ( registered.unreads != room.unread_notifications or registered.highlights != room.unread_highlights @@ -1962,10 +1955,9 @@ class MatrixClient(nio.AsyncClient): last_event_date = last_event_date, - unreads = room.unread_notifications, - highlights = room.unread_highlights, - local_unreads = local_unreads, - local_highlights = local_highlights, + unreads = room.unread_notifications, + highlights = room.unread_highlights, + local_unreads = local_unreads, lexical_sorting = self.backend.settings.RoomList.lexical_sort, bookmarked = room.room_id in bookmarks.get(self.user_id, []), @@ -2272,10 +2264,7 @@ class MatrixClient(nio.AsyncClient): self.previous_server_unreads[room.room_id] = room_item.unreads self.previous_server_highlights[room.room_id] = room_item.highlights - if highlight: - room_item.set_fields(local_unreads=True, local_highlights=True) - else: - room_item.local_unreads = True + room_item.local_unreads = True if unread or highlight: members = self.models[self.user_id, room.room_id, "members"] diff --git a/src/backend/models/items.py b/src/backend/models/items.py index f2650765..3d8395a4 100644 --- a/src/backend/models/items.py +++ b/src/backend/models/items.py @@ -69,7 +69,6 @@ class Account(ModelItem): total_unread: int = 0 total_highlights: int = 0 local_unreads: bool = False - local_highlights: bool = False # For some reason, Account cannot inherit Presence, because QML keeps # complaining type error on unknown file @@ -165,10 +164,9 @@ class Room(ModelItem): last_event_date: datetime = ZERO_DATE - unreads: int = 0 - highlights: int = 0 - local_unreads: bool = False - local_highlights: bool = False + unreads: int = 0 + highlights: int = 0 + local_unreads: bool = False lexical_sorting: bool = False bookmarked: bool = False @@ -207,7 +205,6 @@ class Room(ModelItem): self.left, bool(other.inviter_id), bool(other.highlights), - bool(other.local_highlights), bool(other.unreads), bool(other.local_unreads), other.last_event_date, @@ -220,7 +217,6 @@ class Room(ModelItem): other.left, bool(self.inviter_id), bool(self.highlights), - bool(self.local_highlights), bool(self.unreads), bool(self.local_unreads), self.last_event_date, @@ -264,7 +260,6 @@ class AccountOrRoom(Account, Room): self.left, bool(other.inviter_id), bool(other.highlights), - bool(other.local_highlights), bool(other.unreads), bool(other.local_unreads), other.last_event_date, @@ -279,7 +274,6 @@ class AccountOrRoom(Account, Room): other.left, bool(self.inviter_id), bool(self.highlights), - bool(self.local_highlights), bool(self.unreads), bool(self.local_unreads), self.last_event_date, diff --git a/src/gui/MainPane/AccountDelegate.qml b/src/gui/MainPane/AccountDelegate.qml index 19dc3b5c..83fba60b 100644 --- a/src/gui/MainPane/AccountDelegate.qml +++ b/src/gui/MainPane/AccountDelegate.qml @@ -98,7 +98,6 @@ HTile { unreads: model.total_unread highlights: model.total_highlights localUnreads: model.local_unreads - localHighlights: model.local_highlights } } diff --git a/src/gui/MainPane/MessageIndicator.qml b/src/gui/MainPane/MessageIndicator.qml index 9d819ae6..fe38cb7a 100644 --- a/src/gui/MainPane/MessageIndicator.qml +++ b/src/gui/MainPane/MessageIndicator.qml @@ -11,10 +11,6 @@ HLabel { property int unreads: 0 property int highlights: 0 property bool localUnreads: false - property bool localHighlights: false - - readonly property bool useHighlightStyle: - highlights || (! unreads && localUnreads && localHighlights) text: @@ -25,13 +21,13 @@ HLabel { "" color: - useHighlightStyle ? + highlights ? indicatorTheme.highlightText : indicatorTheme.text font.pixelSize: theme.fontSize.small font.bold: - useHighlightStyle ? + highlights ? indicatorTheme.highlightBold : indicatorTheme.bold @@ -44,22 +40,22 @@ HLabel { background: Rectangle { radius: - useHighlightStyle ? + highlights ? indicatorTheme.highlightRadius : indicatorTheme.radius color: - useHighlightStyle ? + highlights ? indicatorTheme.highlightBackground : indicatorTheme.background border.width: - useHighlightStyle ? + highlights ? indicatorTheme.highlightBorderWidth : indicatorTheme.borderWidth border.color: - useHighlightStyle ? + highlights ? indicatorTheme.highlightBorder : indicatorTheme.border diff --git a/src/gui/MainPane/RoomDelegate.qml b/src/gui/MainPane/RoomDelegate.qml index 5964dd60..54a147af 100644 --- a/src/gui/MainPane/RoomDelegate.qml +++ b/src/gui/MainPane/RoomDelegate.qml @@ -77,7 +77,6 @@ HTile { unreads: model.unreads highlights: model.highlights localUnreads: model.local_unreads - localHighlights: model.local_highlights } HIcon { diff --git a/src/gui/MainPane/RoomList.qml b/src/gui/MainPane/RoomList.qml index ac47ab2f..8e12c7b9 100644 --- a/src/gui/MainPane/RoomList.qml +++ b/src/gui/MainPane/RoomList.qml @@ -93,7 +93,7 @@ HListView { function cycleUnreadRooms(forward=true, highlights=false) { const prop = highlights ? "highlights" : "unreads" - const local_prop = highlights ? "local_highlights" : "local_unreads" + const local_prop = highlights ? "highlights" : "local_unreads" const start = currentIndex === -1 ? 0 : currentIndex let index = start diff --git a/src/gui/Pages/Chat/Timeline/EventList.qml b/src/gui/Pages/Chat/Timeline/EventList.qml index e0b6881c..d35e2279 100644 --- a/src/gui/Pages/Chat/Timeline/EventList.qml +++ b/src/gui/Pages/Chat/Timeline/EventList.qml @@ -627,8 +627,7 @@ Rectangle { ( chat.roomInfo.unreads || chat.roomInfo.highlights || - chat.roomInfo.local_unreads || - chat.roomInfo.local_highlights + chat.roomInfo.local_unreads ) && Qt.application.state === Qt.ApplicationActive && eventList.visibleEnd.y > eventList.contentHeight - 100