From 499555ec6bb91fd4a53fd2f25b958aee80399911 Mon Sep 17 00:00:00 2001 From: Raatty Date: Wed, 5 May 2021 21:31:38 +1200 Subject: [PATCH] content: Show room name and topic in header --- data/resources/ui/content.ui | 14 ++++++++++++++ src/session/room/room.rs | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/data/resources/ui/content.ui b/data/resources/ui/content.ui index bbe493d3..25395e48 100644 --- a/data/resources/ui/content.ui +++ b/data/resources/ui/content.ui @@ -16,6 +16,20 @@ content.go-back + + + + + Content + + + + + Content + + + + view-more-symbolic diff --git a/src/session/room/room.rs b/src/session/room/room.rs index 0b7e3d70..f1782205 100644 --- a/src/session/room/room.rs +++ b/src/session/room/room.rs @@ -118,6 +118,13 @@ mod imp { CategoryType::default() as i32, glib::ParamFlags::READABLE, ), + glib::ParamSpec::new_string( + "topic", + "Topic", + "The topic of this room", + None, + glib::ParamFlags::READABLE, + ), ] }); @@ -153,6 +160,7 @@ mod imp { "timeline" => self.timeline.get().unwrap().to_value(), "category" => obj.category().to_value(), "highlight" => obj.highlight().to_value(), + "topic" => obj.topic().to_value(), "notification-count" => { let highlight = matrix_room.unread_notification_counts().highlight_count; let notification = matrix_room.unread_notification_counts().notification_count; @@ -310,6 +318,12 @@ impl Room { ); } + pub fn topic(&self) -> Option { + self.matrix_room() + .topic() + .filter(|topic| !topic.is_empty() && topic.find(|c: char| !c.is_whitespace()).is_some()) + } + /// Returns the room member `User` object /// /// The returned `User` is specific to this room @@ -339,6 +353,9 @@ impl Room { // FIXME: this doesn't take in account changes in the calculated name self.load_display_name() } + AnyRoomEvent::State(AnyStateEvent::RoomTopic(_)) => { + self.notify("topic"); + } _ => {} } }