Skip to content

Commit

Permalink
message-row: Add initial support for replies chat
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Jun 15, 2023
1 parent d9061a5 commit 4b97196
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/components/avatar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ impl Avatar {
self.load_image(user.avatar(), user.session());
}
} else if let Some(chat) = item.downcast_ref::<Chat>() {
if chat.is_own_chat() {
if chat.is_replies_chat() {
imp.avatar.set_icon_name(Some("mail-reply-sender-symbolic"));
imp.avatar.set_show_initials(false);
} else if chat.is_own_chat() {
imp.avatar.set_icon_name(Some("user-bookmarks-symbolic"));
imp.avatar.set_show_initials(false);
} else {
Expand All @@ -214,7 +217,7 @@ impl Avatar {
imp.avatar
.set_text(Some(&strings::user_display_name(user, true)));
} else if let Some(chat) = item.downcast_ref::<Chat>() {
if chat.is_own_chat() {
if chat.is_own_chat() || chat.is_replies_chat() {
imp.avatar.set_text(Some("-"));
} else {
imp.avatar.set_text(Some(chat.title().as_ref()));
Expand Down
2 changes: 2 additions & 0 deletions src/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub(crate) fn chat_display_name(chat_expression: &gtk::Expression) -> gtk::Expre
let is_deleted = args[3].get::<bool>().unwrap();
if chat.is_own_chat() {
gettext("Saved Messages")
} else if chat.is_replies_chat() {
gettext("Replies")
} else if is_deleted {
gettext("Deleted Account")
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/session/content/chat_action_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,14 @@ impl ChatActionBar {
imp.action_bar_stack.set_visible_child_name("entry");
} else if is_blocked {
imp.action_bar_stack.set_visible_child_name("unblock");
} else if chat.is_replies_chat() {
imp.action_bar_stack.set_visible_child_name("mute");

if self.is_chat_muted() {
imp.mute_button.set_label(&gettext("Unmute"));
} else {
imp.mute_button.set_label(&gettext("Mute"));
}
} else {
imp.action_bar_stack.set_visible_child_name("entry");
}
Expand Down
2 changes: 1 addition & 1 deletion src/session/content/message_row/bubble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl MessageBubble {

let show_sender = if force_hide_sender {
None
} else if message.chat().is_own_chat() {
} else if message.chat().is_own_chat() || message.chat().is_replies_chat() {
if message.is_outgoing() {
None
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/session/content/message_row/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl MessageRow {
if let Some(message) = message.downcast_ref::<Message>() {
let show_avatar = if message.is_outgoing() {
false
} else if message.chat().is_own_chat() {
} else if message.chat().is_own_chat() || message.chat().is_replies_chat() {
message.forward_info().is_some()
} else {
match message.chat().type_() {
Expand Down Expand Up @@ -248,7 +248,7 @@ impl MessageRow {
}
};

if message.chat().is_own_chat() {
if message.chat().is_own_chat() || message.chat().is_replies_chat() {
match message.forward_info().unwrap().origin() {
MessageForwardOrigin::User(user) => {
avatar.set_custom_text(None);
Expand Down
2 changes: 1 addition & 1 deletion src/session/sidebar/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ fn sender_label(message: Message) -> Option<String> {
_ => return None,
}

if message.chat().is_own_chat() {
if message.chat().is_own_chat() || message.chat().is_replies_chat() {
if message.is_outgoing() {
None
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/tdlib/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ impl Chat {
self.type_().user() == Some(&self.session().me())
}

pub(crate) fn is_replies_chat(&self) -> bool {
self.id() == 1271266957 || self.id() == 708513
}

pub(crate) fn permissions(&self) -> BoxedChatPermissions {
self.imp().permissions.borrow().to_owned().unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion src/tdlib/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl Message {
}

pub(crate) fn sender_display_name_expression(&self) -> gtk::Expression {
if self.chat().is_own_chat() {
if self.chat().is_own_chat() || self.chat().is_replies_chat() {
self.forward_info()
.map(MessageForwardInfo::origin)
.map(|forward_origin| match forward_origin {
Expand Down

0 comments on commit 4b97196

Please sign in to comment.