From 252f2ce08661294552f37d529dc3368add3f9ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 26 Nov 2026 03:33:38 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20pinned=20poll=20banner=20?= =?UTF-8?q?pages=20through=20every=20open=20pin,=20poll=20pins=20and=20rep?= =?UTF-8?q?lies=20show=20the=20question,=20ghost=20shows=20as=20ghost=20in?= =?UTF-8?q?=20own=20voice=20panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/chat.rs | 4 ++ crates/client/src/gui/composer.rs | 2 +- crates/client/src/gui/message_actions.rs | 11 +++++- crates/client/src/gui/poll.rs | 48 +++++++++++++++++++++--- crates/client/src/gui/sidebar.rs | 12 +++++- crates/server/src/db/message.rs | 2 +- 6 files changed, 68 insertions(+), 11 deletions(-) diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 9367a26..7a3de94 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -153,6 +153,7 @@ pub struct Chat { pub(super) plus_menu: composer::PlusMenu, pub(super) my_votes: HashMap>, pub(super) poll_expanded: bool, + pub(super) poll_page: usize, scroll: ScrollHandle, pub(super) jump: Option, highlight: Option<(Id, Instant)>, @@ -366,6 +367,7 @@ impl Chat { plus_menu: composer::PlusMenu::Menu, my_votes: HashMap::new(), poll_expanded: false, + poll_page: 0, history: History::End, scroll: ScrollHandle::new(), jump: None, @@ -733,6 +735,7 @@ impl Chat { self.jump = None; self.pins.clear(); self.poll_expanded = false; + self.poll_page = 0; self.my_votes.clear(); self.community_hits.clear(); self.history = History::End; @@ -2468,6 +2471,7 @@ impl Yumush { .chat .voice_ids(community_id) .iter() + .filter(|id| !(self.chat.ghost && self.is_me(**id))) .filter_map(|id| self.chat.member(*id)) .collect(); if users.is_empty() { diff --git a/crates/client/src/gui/composer.rs b/crates/client/src/gui/composer.rs index e7d22b5..10a678a 100644 --- a/crates/client/src/gui/composer.rs +++ b/crates/client/src/gui/composer.rs @@ -142,7 +142,7 @@ fn reply_bar( .to_string(); let quote = message .map(|message| { - super::message_actions::quote_text(&message.body, message.attachments.len() as u32) + super::message_actions::message_text(message) }) .unwrap_or_default(); diff --git a/crates/client/src/gui/message_actions.rs b/crates/client/src/gui/message_actions.rs index bf8d281..df80b21 100644 --- a/crates/client/src/gui/message_actions.rs +++ b/crates/client/src/gui/message_actions.rs @@ -143,6 +143,13 @@ pub fn quote_text(body: &str, attachments: u32) -> String { } } +pub fn message_text(message: &Message) -> String { + match &message.poll { + Some(poll) if message.body.is_empty() => poll.question.clone(), + _ => quote_text(&message.body, message.attachments.len() as u32), + } +} + pub fn quote_line(message: &Message, chat: &Chat, palette: Palette) -> Option { let quote = message.reply.as_ref()?; let author = chat.author(quote.user_id); @@ -265,7 +272,7 @@ pub fn search_popover(chat: &Chat, entity: &Entity, palette: Palette) -> .map(|user| user.username.clone()) .unwrap_or_default(), time: Some(millis_time(hit.message.created_at, CLOCK)), - body: quote_text(&hit.message.body, hit.message.attachments.len() as u32), + body: message_text(&hit.message), }) .collect(); @@ -316,7 +323,7 @@ pub fn pins_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i .map(|user| user.username.clone()) .unwrap_or_default(), time: None, - body: quote_text(&pin.body, pin.attachments.len() as u32), + body: message_text(pin), }) .collect(); diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index 6e80824..b514008 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -418,12 +418,20 @@ pub fn poll_card( impl Yumush { pub(super) fn poll_banner(&self, entity: &Entity, palette: Palette) -> Option
{ - let (message, poll) = self.chat.pins.iter().find_map(|pin| { - pin.poll - .as_ref() - .filter(|poll| !is_closed(poll)) - .map(|poll| (pin, poll)) - })?; + let open: Vec<(&Message, &Poll)> = self + .chat + .pins + .iter() + .filter_map(|pin| { + pin.poll + .as_ref() + .filter(|poll| !is_closed(poll)) + .map(|poll| (pin, poll)) + }) + .collect(); + let count = open.len(); + let page = self.chat.poll_page % count.max(1); + let (message, poll) = *open.get(page)?; let me = self.user.as_ref(); let expanded = self.chat.poll_expanded; let toggle = entity.clone(); @@ -489,6 +497,17 @@ impl Yumush { ), ), ) + .children((count > 1).then(|| { + div() + .flex() + .items_center() + .gap(px(2.)) + .text_size(text(11.)) + .text_color(palette.muted) + .child(page_button("poll_page_back", IconName::ChevronLeft, "Previous", count - 1, entity, palette)) + .child(format!("{}/{count}", page + 1)) + .child(page_button("poll_page_next", IconName::ChevronRight, "Next", 1, entity, palette)) + })) .child(icon_button( "poll_banner_jump", palette, @@ -581,3 +600,20 @@ impl Yumush { }); } } + +fn page_button( + id: &'static str, + icon: IconName, + tip: &'static str, + step: usize, + entity: &Entity, + palette: Palette, +) -> impl IntoElement { + let entity = entity.clone(); + icon_button(id, palette, icon, tip, move |_, cx| { + entity.update(cx, |yumush, cx| { + yumush.chat.poll_page = yumush.chat.poll_page.wrapping_add(step); + cx.notify(); + }); + }) +} diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index a9180a8..70ded4c 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -244,6 +244,7 @@ impl Yumush { let watch_screen = entity.clone(); let watch_camera = entity.clone(); let sharing = self.chat.waves.share(user_id).is_some(); + let ghost = self.chat.ghost && self.is_me(user_id); let member = profile_popover( format!("voice_member_{user_id}"), @@ -274,7 +275,15 @@ impl Yumush { .text_size(text(12.)) .text_color(palette.text) .child(user.username.clone()), - ), + ) + .when(ghost, |row| { + row.child( + Icon::new(IconName::Ghost) + .w(px(12.)) + .h(px(12.)) + .text_color(palette.muted), + ) + }), ); div() @@ -284,6 +293,7 @@ impl Yumush { .px(px(4.)) .py(px(2.)) .rounded(px(6.)) + .when(ghost, |row| row.opacity(0.5)) .hover(move |style| style.bg(palette.hover)) .child(div().flex_1().min_w_0().child(member)) .child( diff --git a/crates/server/src/db/message.rs b/crates/server/src/db/message.rs index afbe5f5..bd4025c 100644 --- a/crates/server/src/db/message.rs +++ b/crates/server/src/db/message.rs @@ -11,7 +11,7 @@ use crate::error::{ServerError, ensure_with}; const SEARCH_LIMIT: u32 = 200; const PAGE_LIMIT: u32 = MESSAGE_PAGE_LIMIT as u32; -const SELECT: &str = "SELECT m.id, m.user_id, m.community_id, m.created_at, m.body, m.edited, r.id, r.user_id, r.body, (SELECT COUNT(*) FROM attachment a WHERE a.message_id = r.id AND a.snippet_position IS NULL), m.call, m.call_seconds, m.pinned FROM message m LEFT JOIN message r ON r.id = m.reply_to"; +const SELECT: &str = "SELECT m.id, m.user_id, m.community_id, m.created_at, m.body, m.edited, r.id, r.user_id, COALESCE(NULLIF(r.body, ''), (SELECT question FROM poll p WHERE p.message_id = r.id), r.body), (SELECT COUNT(*) FROM attachment a WHERE a.message_id = r.id AND a.snippet_position IS NULL), m.call, m.call_seconds, m.pinned FROM message m LEFT JOIN message r ON r.id = m.reply_to"; fn row(r: &mut Reader) -> Result { let id = r.get()?;