Clicking '(deleted)' on an expanded deleted message collapses it again
Browse files at this commit7f93e5a28738d26effc345df3136a79ad2251150Parent: fb89d65- style
- clicking '(deleted)' on an expanded deleted message collapses it again
- members column shows every offline member, no 'N more' cap
2 changed files +25 -43
crates/client/src/gui/chat.rsmodified+11 -43
| @@ -275,7 +275,6 @@ pub struct Chat { | |||
| 275 | pub(super) followed: Option<(Id, common::stats::Stats)>, | 275 | pub(super) followed: Option<(Id, common::stats::Stats)>, |
| 276 | pub(super) share_loss: HashMap<(Id, Kind), VecDeque<(u64, f32)>>, | 276 | pub(super) share_loss: HashMap<(Id, Kind), VecDeque<(u64, f32)>>, |
| 277 | pub(super) stats_at: Option<StatsAt>, | 277 | pub(super) stats_at: Option<StatsAt>, |
| 278 | - pub(super) offline_open: bool, | ||
| 279 | pub(super) usage_monitor: crate::usage::Monitor, | 278 | pub(super) usage_monitor: crate::usage::Monitor, |
| 280 | pub(super) ringing: HashSet<Id>, | 279 | pub(super) ringing: HashSet<Id>, |
| 281 | pub(super) ring_task: Option<Task<()>>, | 280 | pub(super) ring_task: Option<Task<()>>, |
| @@ -571,7 +570,6 @@ impl Chat { | |||
| 571 | followed: None, | 570 | followed: None, |
| 572 | share_loss: HashMap::new(), | 571 | share_loss: HashMap::new(), |
| 573 | stats_at: None, | 572 | stats_at: None, |
| 574 | - offline_open: false, | ||
| 575 | usage_monitor: { | 573 | usage_monitor: { |
| 576 | let monitor = crate::usage::Monitor::default(); | 574 | let monitor = crate::usage::Monitor::default(); |
| 577 | if let Some(dir) = crate::config_dir() { | 575 | if let Some(dir) = crate::config_dir() { |
| @@ -3290,39 +3288,16 @@ fn members_column( | |||
| 3290 | .children(watch(Kind::Camera)) | 3288 | .children(watch(Kind::Camera)) |
| 3291 | .children(watch(Kind::Screen)) | 3289 | .children(watch(Kind::Screen)) |
| 3292 | }; | 3290 | }; |
| 3293 | - let section = |title: &'static str, rows: Vec<&MemberRow>, cap: usize| { | 3291 | + let section = |title: &'static str, rows: Vec<&MemberRow>| { |
| 3294 | (!rows.is_empty()).then(|| { | 3292 | (!rows.is_empty()).then(|| { |
| 3295 | - let total = rows.len(); | ||
| 3296 | - let more = total.saturating_sub(cap); | ||
| 3297 | div() | 3293 | div() |
| 3298 | .flex() | 3294 | .flex() |
| 3299 | .flex_col() | 3295 | .flex_col() |
| 3300 | .child( | 3296 | .child( |
| 3301 | - super::parts::caption_head(format!("{title} · {total}"), palette.tokens) | 3297 | + super::parts::caption_head(format!("{title} · {}", rows.len()), palette.tokens) |
| 3302 | .pb(px(space::XS)), | 3298 | .pb(px(space::XS)), |
| 3303 | ) | 3299 | ) |
| 3304 | - .children(rows.into_iter().take(cap).map(row)) | 3300 | + .children(rows.into_iter().map(row)) |
| 3305 | - .when(more > 0, |this| { | ||
| 3306 | - this.child( | ||
| 3307 | - clickable( | ||
| 3308 | - "offline_more", | ||
| 3309 | - palette, | ||
| 3310 | - entity_action(&entity, |yumush, _, cx| { | ||
| 3311 | - yumush.chat.offline_open = true; | ||
| 3312 | - cx.notify(); | ||
| 3313 | - }), | ||
| 3314 | - ) | ||
| 3315 | - .h(px(size::CONTROL)) | ||
| 3316 | - .px(px(space::SM)) | ||
| 3317 | - .pl(px(space::SM + size::ICON + space::SM)) | ||
| 3318 | - .flex() | ||
| 3319 | - .items_center() | ||
| 3320 | - .rounded(px(radius::MD)) | ||
| 3321 | - .text_size(text(text::CAPTION)) | ||
| 3322 | - .text_color(palette.muted) | ||
| 3323 | - .child(w().common.more(more)), | ||
| 3324 | - ) | ||
| 3325 | - }) | ||
| 3326 | }) | 3301 | }) |
| 3327 | }; | 3302 | }; |
| 3328 | let in_call: Vec<&MemberRow> = members.iter().filter(|row| row.in_voice).collect(); | 3303 | let in_call: Vec<&MemberRow> = members.iter().filter(|row| row.in_voice).collect(); |
| @@ -3344,7 +3319,7 @@ fn members_column( | |||
| 3344 | .flex_col() | 3319 | .flex_col() |
| 3345 | .gap(px(space::SM)) | 3320 | .gap(px(space::SM)) |
| 3346 | .children(join) | 3321 | .children(join) |
| 3347 | - .children(section(w().chat.in_voice, in_call, usize::MAX)) | 3322 | + .children(section(w().chat.in_voice, in_call)) |
| 3348 | }); | 3323 | }); |
| 3349 | let online = members | 3324 | let online = members |
| 3350 | .iter() | 3325 | .iter() |
| @@ -3366,20 +3341,11 @@ fn members_column( | |||
| 3366 | .gap(px(space::LG)) | 3341 | .gap(px(space::LG)) |
| 3367 | .child(room_head(yumush, palette)) | 3342 | .child(room_head(yumush, palette)) |
| 3368 | .children(call) | 3343 | .children(call) |
| 3369 | - .children(section(w().common.presence_online, online, usize::MAX)) | 3344 | + .children(section(w().common.presence_online, online)) |
| 3370 | - .children(section( | 3345 | + .children(section(w().common.presence_offline, offline)), |
| 3371 | - w().common.presence_offline, | ||
| 3372 | - offline, | ||
| 3373 | - if chat.offline_open { | ||
| 3374 | - usize::MAX | ||
| 3375 | - } else { | ||
| 3376 | - OFFLINE | ||
| 3377 | - }, | ||
| 3378 | - )), | ||
| 3379 | ) | 3346 | ) |
| 3380 | } | 3347 | } |
| 3381 | 3348 | ||
| 3382 | -const OFFLINE: usize = 5; | ||
| 3383 | const GLIDE: Duration = Duration::from_millis(240); | 3349 | const GLIDE: Duration = Duration::from_millis(240); |
| 3384 | const GLIDE_SLACK: Duration = Duration::from_millis(100); | 3350 | const GLIDE_SLACK: Duration = Duration::from_millis(100); |
| 3385 | 3351 | ||
| @@ -3736,9 +3702,11 @@ fn render_message( | |||
| 3736 | message, builder, entity, palette, | 3702 | message, builder, entity, palette, |
| 3737 | ) | 3703 | ) |
| 3738 | })) | 3704 | })) |
| 3739 | - .children( | 3705 | + .children(message.deleted.then(|| { |
| 3740 | - message.deleted.then(|| w().chat.deleted), | 3706 | + message_actions::collapse_deleted( |
| 3741 | - ), | 3707 | + message.id, entity, |
| 3708 | + ) | ||
| 3709 | + })), | ||
| 3742 | ) | 3710 | ) |
| 3743 | }), | 3711 | }), |
| 3744 | ) | 3712 | ) |
crates/client/src/gui/message_actions.rsmodified+14 -0
| @@ -236,6 +236,20 @@ pub fn reveal_deleted(message_id: Id, entity: &Entity<Yumush>, palette: Palette) | |||
| 236 | ) | 236 | ) |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | +pub fn collapse_deleted(message_id: Id, entity: &Entity<Yumush>) -> Stateful<Div> { | ||
| 240 | + let entity = entity.clone(); | ||
| 241 | + div() | ||
| 242 | + .id(format!("collapse_{message_id}")) | ||
| 243 | + .cursor_pointer() | ||
| 244 | + .on_click(move |_, _, cx| { | ||
| 245 | + entity.update(cx, |yumush, cx| { | ||
| 246 | + yumush.chat.revealed.remove(&message_id); | ||
| 247 | + cx.notify(); | ||
| 248 | + }) | ||
| 249 | + }) | ||
| 250 | + .child(w().chat.deleted) | ||
| 251 | +} | ||
| 252 | + | ||
| 239 | pub fn edited_mark( | 253 | pub fn edited_mark( |
| 240 | message: &Message, | 254 | message: &Message, |
| 241 | builder: bool, | 255 | builder: bool, |