[fractal/fractal-next] sidebar: Always show the total number of notifications
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] sidebar: Always show the total number of notifications
- Date: Mon, 28 Mar 2022 14:57:16 +0000 (UTC)
commit 0e5886bedf208cbf874cac889a77ea9e724857ad
Author: Kévin Commaille <zecakeh tedomum fr>
Date: Sun Mar 27 18:47:24 2022 +0200
sidebar: Always show the total number of notifications
src/session/room/mod.rs | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/session/room/mod.rs b/src/session/room/mod.rs
index 3bd95d9ab..abfd29a06 100644
--- a/src/session/room/mod.rs
+++ b/src/session/room/mod.rs
@@ -245,8 +245,6 @@ mod imp {
}
fn property(&self, obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
- let matrix_room = self.matrix_room.borrow();
- let matrix_room = matrix_room.as_ref().unwrap();
match pspec.name() {
"room-id" => obj.room_id().as_str().to_value(),
"session" => obj.session().to_value(),
@@ -258,17 +256,7 @@ mod imp {
"highlight" => obj.highlight().to_value(),
"topic" => obj.topic().to_value(),
"members" => obj.members().to_value(),
- "notification-count" => {
- let highlight = matrix_room.unread_notification_counts().highlight_count;
- let notification = matrix_room.unread_notification_counts().notification_count;
-
- if highlight > 0 {
- highlight
- } else {
- notification
- }
- .to_value()
- }
+ "notification-count" => obj.notification_count().to_value(),
"latest-change" => obj.latest_change().to_value(),
"predecessor" => obj.predecessor().map_or_else(
|| {
@@ -675,6 +663,16 @@ impl Room {
);
}
+ /// The number of unread notifications of this room.
+ pub fn notification_count(&self) -> u64 {
+ let matrix_room = self.imp().matrix_room.borrow();
+ matrix_room
+ .as_ref()
+ .unwrap()
+ .unread_notification_counts()
+ .notification_count
+ }
+
/// Updates the Matrix room with the given name.
pub fn store_room_name(&self, room_name: String) {
if self.display_name() == room_name {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]