forge
Explore
Log in

Don't you dare go Hollow

Reply quotes: multi-line bodies spilled over the chat (whitespace now flattened to one line), clicking a quote jumps to the message, and quotes follow edits / vanish on delete like the server's ON DELETE SET NULL

Browse files at this commit

4f81f38e4d6e883e786adfeee3afbde53cf4ba02Ahmet Kaan GümüşParent: 787d3e8
  • fix
    • reply quotes: multi-line bodies spilled over the chat (whitespace now flattened to one line), clicking a quote jumps to the message, and quotes follow edits / vanish on delete like the server's ON DELETE SET NULL
Show full message
🐛 fix: reply quotes: multi-line bodies spilled over the chat (whitespace now flattened to one line), clicking a quote jumps to the message, and quotes follow edits / vanish on delete like the server's ON DELETE SET NULL
crates/client/src/gui/chat.rsmodified+25 -2
@@ -660,7 +660,14 @@ impl Chat {
660660 .iter_mut()
661661 .find(|existing| existing.id == message.id)
662662 {
663- *existing = message;
663+ *existing = message.clone();
664+ }
665+ let body = match &message.poll {
666+ Some(poll) if message.body.is_empty() => poll.question.clone(),
667+ _ => message.body.clone(),
668+ };
669+ for quote in self.quotes_of(message.id) {
670+ quote.body = body.clone();
664671 }
665672 }
666673 }
@@ -868,8 +875,24 @@ impl Chat {
868875 .any(|community| community.id == community_id)
869876 }
870877
878+ fn quotes_of(&mut self, message_id: Id) -> impl Iterator<Item = &mut common::model::Quote> {
879+ self.messages
880+ .iter_mut()
881+ .filter_map(|message| message.reply.as_mut())
882+ .filter(move |quote| quote.message_id == message_id)
883+ }
884+
871885 fn forget_message(&mut self, message_id: Id) {
872886 self.messages.retain(|existing| existing.id != message_id);
887+ for message in &mut self.messages {
888+ if message
889+ .reply
890+ .as_ref()
891+ .is_some_and(|quote| quote.message_id == message_id)
892+ {
893+ message.reply = None;
894+ }
895+ }
873896
874897 match &mut self.composer {
875898 Composer::Select { ids } => ids.retain(|id| *id != message_id),
@@ -3619,7 +3642,7 @@ fn render_message(
36193642 .flex()
36203643 .flex_col()
36213644 .gap(px(space::SM))
3622- .children(message_actions::quote_line(message, chat, palette))
3645+ .children(message_actions::quote_line(message, chat, entity, palette))
36233646 .when(!message.body.is_empty(), |this| {
36243647 this.child(
36253648 div()
crates/client/src/gui/message_actions.rsmodified+15 -3
@@ -138,10 +138,10 @@ pub fn react_popover(
138138 }
139139
140140 pub fn quote_text(body: &str, attachments: u32) -> String {
141- if body.is_empty() {
141+ if body.trim().is_empty() {
142142 w().message_actions.attachments(attachments)
143143 } else {
144- body.to_string()
144+ body.split_whitespace().collect::<Vec<_>>().join(" ")
145145 }
146146 }
147147
@@ -152,12 +152,24 @@ pub fn message_text(message: &Message) -> String {
152152 }
153153 }
154154
155-pub fn quote_line(message: &Message, chat: &Chat, palette: Palette) -> Option<impl IntoElement> {
155+pub fn quote_line(
156+ message: &Message,
157+ chat: &Chat,
158+ entity: &Entity<Yumush>,
159+ palette: Palette,
160+) -> Option<impl IntoElement> {
156161 let quote = message.reply.as_ref()?;
157162 let author = chat.author(quote.user_id);
163+ let target = quote.message_id;
164+ let entity = entity.clone();
158165
159166 Some(
160167 div()
168+ .id(format!("quote_{}", message.id))
169+ .cursor_pointer()
170+ .on_click(move |_, window, cx| {
171+ entity.update(cx, |yumush, cx| yumush.go_to_message(target, window, cx))
172+ })
161173 .flex()
162174 .items_center()
163175 .gap(px(space::SM))