Browse Source

misc: Linkify room topics in more places

fractal-8
Kévin Commaille 2 years ago
parent
commit
a8f40acb9a
No known key found for this signature in database
GPG Key ID: C971D9DBC9D678D
  1. 2
      src/components/dialogs/join_room.rs
  2. 2
      src/components/dialogs/join_room.ui
  3. 22
      src/session/model/remote_room.rs
  4. 8
      src/session/view/content/explore/public_room_row.rs
  5. 2
      src/session/view/content/explore/public_room_row.ui
  6. 5
      src/session/view/content/invite.ui

2
src/components/dialogs/join_room.rs

@ -271,7 +271,7 @@ impl JoinRoomDialog {
return;
}
if let Some(topic) = room.topic() {
if let Some(topic) = room.topic_linkified() {
imp.room_topic.set_label(&topic);
imp.room_topic.set_visible(true);
} else {

2
src/components/dialogs/join_room.ui

@ -162,6 +162,8 @@
<property name="wrap">true</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
<property name="use-markup">True</property>
<property name="selectable">True</property>
</object>
</child>
<child>

22
src/session/model/remote_room.rs

@ -12,7 +12,7 @@ use crate::{
components::{AvatarImage, AvatarUriSource, PillSource},
prelude::*,
spawn, spawn_tokio,
utils::{matrix::MatrixRoomIdUri, LoadingState},
utils::{matrix::MatrixRoomIdUri, string::linkify, LoadingState},
};
mod imp {
@ -41,6 +41,12 @@ mod imp {
/// The topic of this room.
#[property(get)]
pub topic: RefCell<Option<String>>,
/// The linkified topic of this room.
///
/// This is the string that should be used in the interface when markup
/// is allowed.
#[property(get)]
pub topic_linkified: RefCell<Option<String>>,
/// The number of joined members in the room.
#[property(get)]
pub joined_members_count: Cell<u32>,
@ -129,8 +135,20 @@ mod imp {
return;
}
let topic_linkified = topic.as_deref().map(|t| {
// Detect links.
let mut s = linkify(t);
// Remove trailing spaces.
s.truncate_end_whitespaces();
s
});
self.topic.replace(topic);
self.obj().notify_topic();
self.topic_linkified.replace(topic_linkified);
let obj = self.obj();
obj.notify_topic();
obj.notify_topic_linkified();
}
/// Set the loading state.

8
src/session/view/content/explore/public_room_row.rs

@ -9,7 +9,7 @@ use crate::{
gettext_f, ngettext_f,
prelude::*,
spawn, toast,
utils::BoundObject,
utils::{string::linkify, BoundObject},
Window,
};
@ -138,7 +138,11 @@ mod imp {
self.display_name.set_text(&public_room.display_name());
if let Some(topic) = &matrix_public_room.topic {
self.description.set_text(topic);
// Detect links.
let mut t = linkify(topic);
// Remove trailing spaces.
t.truncate_end_whitespaces();
self.description.set_label(&t);
}
self.description
.set_visible(matrix_public_room.topic.is_some());

2
src/session/view/content/explore/public_room_row.ui

@ -39,6 +39,8 @@
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="xalign">0</property>
<property name="use-markup">True</property>
<property name="selectable">True</property>
</object>
</child>
<child>

5
src/session/view/content/invite.ui

@ -68,6 +68,7 @@
<child>
<object class="GtkLabel" id="room_alias">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
<binding name="label">
<lookup name="alias-string">
@ -86,9 +87,11 @@
<child>
<object class="GtkLabel" id="room_topic">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
<property name="use-markup">True</property>
<binding name="label">
<lookup name="topic">
<lookup name="topic-linkified">
<lookup name="room">ContentInvite</lookup>
</lookup>
</binding>

Loading…
Cancel
Save