Own anonymous poll votes sync across sessions, toggle tooltips refresh on state change
Browse files at this commit05ce84ce36dc24177d08746a5c7e22dee4e2af56Parent: 66b1921- fix
- own anonymous poll votes sync across sessions, toggle tooltips refresh on state change
13 changed files +54 -20
- crates/client/src/gui/builder/communities.rs +2 -2
- crates/client/src/gui/builder/messages.rs +1 -1
- crates/client/src/gui/builder/ui.rs +2 -2
- crates/client/src/gui/builder/users.rs +2 -2
- crates/client/src/gui/builder/voice.rs +2 -2
- crates/client/src/gui/camera_view.rs +5 -1
- crates/client/src/gui/chat.rs +16 -5
- crates/client/src/gui/media_view.rs +1 -1
- crates/client/src/gui/poll.rs +1 -1
- crates/client/src/gui/share_view.rs +6 -2
- crates/client/src/gui/sidebar.rs +5 -1
- crates/common/src/event.rs +4 -0
- crates/server/src/call/message.rs +7 -0
crates/client/src/gui/builder/communities.rsmodified+2 -2
| @@ -440,7 +440,7 @@ impl Yumush { | |||
| 440 | }), | 440 | }), |
| 441 | )) | 441 | )) |
| 442 | .child(icon_button( | 442 | .child(icon_button( |
| 443 | - format!("voice_community_{id}"), | 443 | + format!("voice_community_{id}_{voice_enabled}"), |
| 444 | if voice_enabled { | 444 | if voice_enabled { |
| 445 | IconName::Phone | 445 | IconName::Phone |
| 446 | } else { | 446 | } else { |
| @@ -473,7 +473,7 @@ impl Yumush { | |||
| 473 | )) | 473 | )) |
| 474 | .child( | 474 | .child( |
| 475 | icon_button( | 475 | icon_button( |
| 476 | - format!("delete_community_{id}"), | 476 | + format!("delete_community_{id}_{pending_delete}"), |
| 477 | IconName::Trash, | 477 | IconName::Trash, |
| 478 | if pending_delete { | 478 | if pending_delete { |
| 479 | "Confirm delete" | 479 | "Confirm delete" |
crates/client/src/gui/builder/messages.rsmodified+1 -1
| @@ -57,7 +57,7 @@ fn message_hit_row( | |||
| 57 | let purge = hit.author.as_ref().map(|author| { | 57 | let purge = hit.author.as_ref().map(|author| { |
| 58 | let user_id = author.id; | 58 | let user_id = author.id; |
| 59 | icon_button( | 59 | icon_button( |
| 60 | - format!("purge_message_user_{}", hit.message.id), | 60 | + format!("purge_message_user_{}_{purge_pending}", hit.message.id), |
| 61 | IconName::UserX, | 61 | IconName::UserX, |
| 62 | if purge_pending { | 62 | if purge_pending { |
| 63 | "Confirm purge" | 63 | "Confirm purge" |
crates/client/src/gui/builder/ui.rsmodified+2 -2
| @@ -53,7 +53,7 @@ pub(super) fn delete_icon_button( | |||
| 53 | action: impl Fn(&mut Window, &mut App) + 'static, | 53 | action: impl Fn(&mut Window, &mut App) + 'static, |
| 54 | ) -> Stateful<Div> { | 54 | ) -> Stateful<Div> { |
| 55 | icon_button( | 55 | icon_button( |
| 56 | - id, | 56 | + format!("{id}_{pending}"), |
| 57 | IconName::Trash, | 57 | IconName::Trash, |
| 58 | if pending { "Confirm" } else { "Delete" }, | 58 | if pending { "Confirm" } else { "Delete" }, |
| 59 | palette.danger, | 59 | palette.danger, |
| @@ -99,7 +99,7 @@ pub(super) fn confirm_button( | |||
| 99 | action: impl Fn(&mut Window, &mut App) + 'static, | 99 | action: impl Fn(&mut Window, &mut App) + 'static, |
| 100 | ) -> Stateful<Div> { | 100 | ) -> Stateful<Div> { |
| 101 | action_button( | 101 | action_button( |
| 102 | - id, | 102 | + format!("{id}_{pending}"), |
| 103 | icon, | 103 | icon, |
| 104 | if pending { "Confirm" } else { label }, | 104 | if pending { "Confirm" } else { label }, |
| 105 | if pending { | 105 | if pending { |
crates/client/src/gui/builder/users.rsmodified+2 -2
| @@ -703,7 +703,7 @@ impl Yumush { | |||
| 703 | 703 | ||
| 704 | let tone = palette.text; | 704 | let tone = palette.text; |
| 705 | let role_button = action_button( | 705 | let role_button = action_button( |
| 706 | - format!("role_{}", user.id), | 706 | + format!("role_{}_{builder}", user.id), |
| 707 | if builder { | 707 | if builder { |
| 708 | IconName::ShieldOff | 708 | IconName::ShieldOff |
| 709 | } else { | 709 | } else { |
| @@ -727,7 +727,7 @@ impl Yumush { | |||
| 727 | ); | 727 | ); |
| 728 | 728 | ||
| 729 | let suspend_button = action_button( | 729 | let suspend_button = action_button( |
| 730 | - format!("suspend_user_{}", user.id), | 730 | + format!("suspend_user_{}_{suspended}", user.id), |
| 731 | IconName::CirclePause, | 731 | IconName::CirclePause, |
| 732 | if suspended { "Unsuspend" } else { "Suspend" }, | 732 | if suspended { "Unsuspend" } else { "Suspend" }, |
| 733 | if suspended { | 733 | if suspended { |
crates/client/src/gui/builder/voice.rsmodified+2 -2
| @@ -124,7 +124,7 @@ impl Yumush { | |||
| 124 | if let Some(enabled) = voice { | 124 | if let Some(enabled) = voice { |
| 125 | actions.push( | 125 | actions.push( |
| 126 | icon_button( | 126 | icon_button( |
| 127 | - format!("room_voice_{id}"), | 127 | + format!("room_voice_{id}_{enabled}"), |
| 128 | if enabled { | 128 | if enabled { |
| 129 | IconName::Phone | 129 | IconName::Phone |
| 130 | } else { | 130 | } else { |
| @@ -208,7 +208,7 @@ impl Yumush { | |||
| 208 | .children(muted.then(|| pill("Muted", palette.danger, palette))) | 208 | .children(muted.then(|| pill("Muted", palette.danger, palette))) |
| 209 | .children(ghost.then(|| pill("Ghost", palette.muted, palette))) | 209 | .children(ghost.then(|| pill("Ghost", palette.muted, palette))) |
| 210 | .child(icon_button( | 210 | .child(icon_button( |
| 211 | - format!("voice_mute_{id}"), | 211 | + format!("voice_mute_{id}_{muted}"), |
| 212 | if muted { | 212 | if muted { |
| 213 | IconName::Mic | 213 | IconName::Mic |
| 214 | } else { | 214 | } else { |
crates/client/src/gui/camera_view.rsmodified+5 -1
| @@ -323,7 +323,11 @@ pub(super) fn camera_toggle( | |||
| 323 | let entity = entity.clone(); | 323 | let entity = entity.clone(); |
| 324 | 324 | ||
| 325 | icon_button( | 325 | icon_button( |
| 326 | - "camera_toggle", | 326 | + if on { |
| 327 | + "camera_toggle_on" | ||
| 328 | + } else { | ||
| 329 | + "camera_toggle_off" | ||
| 330 | + }, | ||
| 327 | palette, | 331 | palette, |
| 328 | if on { | 332 | if on { |
| 329 | IconName::VideoOff | 333 | IconName::VideoOff |
crates/client/src/gui/chat.rsmodified+16 -5
| @@ -560,6 +560,12 @@ impl Chat { | |||
| 560 | } | 560 | } |
| 561 | } | 561 | } |
| 562 | } | 562 | } |
| 563 | + Event::MyVotes { | ||
| 564 | + message_id, | ||
| 565 | + positions, | ||
| 566 | + } => { | ||
| 567 | + self.my_votes.insert(message_id, positions); | ||
| 568 | + } | ||
| 563 | Event::MessagesDeleted { community_id, ids } => { | 569 | Event::MessagesDeleted { community_id, ids } => { |
| 564 | if self.is_selected(community_id) { | 570 | if self.is_selected(community_id) { |
| 565 | for id in ids { | 571 | for id in ids { |
| @@ -2285,11 +2291,12 @@ impl Yumush { | |||
| 2285 | (false, false) => (IconName::Headphones, "Join voice"), | 2291 | (false, false) => (IconName::Headphones, "Join voice"), |
| 2286 | (false, true) => (IconName::Headphones, "Leave voice"), | 2292 | (false, true) => (IconName::Headphones, "Leave voice"), |
| 2287 | }; | 2293 | }; |
| 2294 | + let id = format!("voice_button_{direct}_{in_voice}"); | ||
| 2288 | let button = if in_voice { | 2295 | let button = if in_voice { |
| 2289 | - primary_button("voice_button", palette, on_click) | 2296 | + primary_button(id.clone(), palette, on_click) |
| 2290 | .when(direct, |button| button.bg(palette.danger)) | 2297 | .when(direct, |button| button.bg(palette.danger)) |
| 2291 | } else { | 2298 | } else { |
| 2292 | - clickable("voice_button", palette, on_click).text_color(palette.accent) | 2299 | + clickable(id, palette, on_click).text_color(palette.accent) |
| 2293 | }; | 2300 | }; |
| 2294 | 2301 | ||
| 2295 | Some( | 2302 | Some( |
| @@ -2484,7 +2491,11 @@ impl Yumush { | |||
| 2484 | self.in_stage_chat() | 2491 | self.in_stage_chat() |
| 2485 | .then(|| { | 2492 | .then(|| { |
| 2486 | clickable( | 2493 | clickable( |
| 2487 | - "stage_toggle", | 2494 | + if hidden { |
| 2495 | + "stage_toggle_hidden" | ||
| 2496 | + } else { | ||
| 2497 | + "stage_toggle_shown" | ||
| 2498 | + }, | ||
| 2488 | palette, | 2499 | palette, |
| 2489 | entity_action(entity, |yumush: &mut Yumush, _, cx| { | 2500 | entity_action(entity, |yumush: &mut Yumush, _, cx| { |
| 2490 | camera_view::stage_toggle(yumush, cx) | 2501 | camera_view::stage_toggle(yumush, cx) |
| @@ -2532,7 +2543,7 @@ impl Yumush { | |||
| 2532 | .items_center() | 2543 | .items_center() |
| 2533 | .child( | 2544 | .child( |
| 2534 | icon_button( | 2545 | icon_button( |
| 2535 | - "mic_button", | 2546 | + format!("mic_button_{muted}_{}", self.hidden_in_voice()), |
| 2536 | palette, | 2547 | palette, |
| 2537 | mic_icon, | 2548 | mic_icon, |
| 2538 | match (muted, self.hidden_in_voice()) { | 2549 | match (muted, self.hidden_in_voice()) { |
| @@ -2552,7 +2563,7 @@ impl Yumush { | |||
| 2552 | ) | 2563 | ) |
| 2553 | .child( | 2564 | .child( |
| 2554 | icon_button( | 2565 | icon_button( |
| 2555 | - "deafen_button", | 2566 | + format!("deafen_button_{deafened}"), |
| 2556 | palette, | 2567 | palette, |
| 2557 | deafen_icon, | 2568 | deafen_icon, |
| 2558 | if deafened { "Undeafen" } else { "Deafen" }, | 2569 | if deafened { "Undeafen" } else { "Deafen" }, |
crates/client/src/gui/media_view.rsmodified+1 -1
| @@ -692,7 +692,7 @@ fn player_view( | |||
| 692 | .map(|playing| &playing.state); | 692 | .map(|playing| &playing.state); |
| 693 | let playing = matches!(state, Some(PlayState::Ready { player, .. }) if player.playing()); | 693 | let playing = matches!(state, Some(PlayState::Ready { player, .. }) if player.playing()); |
| 694 | let toggle = icon_button( | 694 | let toggle = icon_button( |
| 695 | - format!("play_{}", attachment.id), | 695 | + format!("play_{}_{playing}", attachment.id), |
| 696 | if playing { | 696 | if playing { |
| 697 | IconName::Pause | 697 | IconName::Pause |
| 698 | } else { | 698 | } else { |
crates/client/src/gui/poll.rsmodified+1 -1
| @@ -258,7 +258,7 @@ pub fn poll_card( | |||
| 258 | .items_center() | 258 | .items_center() |
| 259 | .gap(px(6.)) | 259 | .gap(px(6.)) |
| 260 | .child(status_icon( | 260 | .child(status_icon( |
| 261 | - format!("poll_public_{key}"), | 261 | + format!("poll_public_{key}_{}", poll.public), |
| 262 | visibility, | 262 | visibility, |
| 263 | visibility_tip, | 263 | visibility_tip, |
| 264 | palette, | 264 | palette, |
crates/client/src/gui/share_view.rsmodified+6 -2
| @@ -359,7 +359,11 @@ impl Yumush { | |||
| 359 | )) | 359 | )) |
| 360 | .child( | 360 | .child( |
| 361 | icon_button( | 361 | icon_button( |
| 362 | - "share_toggle", | 362 | + if sharing { |
| 363 | + "share_toggle_on" | ||
| 364 | + } else { | ||
| 365 | + "share_toggle_off" | ||
| 366 | + }, | ||
| 363 | palette, | 367 | palette, |
| 364 | if sharing { | 368 | if sharing { |
| 365 | IconName::ScreenShareOff | 369 | IconName::ScreenShareOff |
| @@ -505,7 +509,7 @@ impl Yumush { | |||
| 505 | }), | 509 | }), |
| 506 | ) | 510 | ) |
| 507 | .child(icon_button( | 511 | .child(icon_button( |
| 508 | - "share_fullscreen".to_string(), | 512 | + format!("share_fullscreen_{}", viewer.fullscreen), |
| 509 | palette, | 513 | palette, |
| 510 | fullscreen_icon, | 514 | fullscreen_icon, |
| 511 | fullscreen_tip, | 515 | fullscreen_tip, |
crates/client/src/gui/sidebar.rsmodified+5 -1
| @@ -366,7 +366,11 @@ impl Yumush { | |||
| 366 | }; | 366 | }; |
| 367 | 367 | ||
| 368 | icon_button( | 368 | icon_button( |
| 369 | - "sidebar_collapse", | 369 | + if self.chat.sidebar_collapsed { |
| 370 | + "sidebar_expand" | ||
| 371 | + } else { | ||
| 372 | + "sidebar_collapse" | ||
| 373 | + }, | ||
| 370 | palette, | 374 | palette, |
| 371 | icon, | 375 | icon, |
| 372 | tip, | 376 | tip, |
crates/common/src/event.rsmodified+4 -0
| @@ -10,6 +10,10 @@ use crate::share::{Kind, Layer, Share}; | |||
| 10 | pub enum Event { | 10 | pub enum Event { |
| 11 | MessageCreated(Message), | 11 | MessageCreated(Message), |
| 12 | MessageUpdated(Message), | 12 | MessageUpdated(Message), |
| 13 | + MyVotes { | ||
| 14 | + message_id: Id, | ||
| 15 | + positions: Vec<u32>, | ||
| 16 | + }, | ||
| 13 | MessagesDeleted { | 17 | MessagesDeleted { |
| 14 | community_id: Id, | 18 | community_id: Id, |
| 15 | ids: Vec<Id>, | 19 | ids: Vec<Id>, |
crates/server/src/call/message.rsmodified+7 -0
| @@ -188,6 +188,13 @@ impl Handle for Vote { | |||
| 188 | validate_vote(poll, &self.positions)?; | 188 | validate_vote(poll, &self.positions)?; |
| 189 | let updated = db::message::vote(self.message_id, me.id, &self.positions, cx.db).await?; | 189 | let updated = db::message::vote(self.message_id, me.id, &self.positions, cx.db).await?; |
| 190 | cx.out.push(message_event(&updated, Event::MessageUpdated)); | 190 | cx.out.push(message_event(&updated, Event::MessageUpdated)); |
| 191 | + cx.emit( | ||
| 192 | + To::User(me.id), | ||
| 193 | + Event::MyVotes { | ||
| 194 | + message_id: self.message_id, | ||
| 195 | + positions: self.positions.clone(), | ||
| 196 | + }, | ||
| 197 | + ); | ||
| 191 | 198 | ||
| 192 | Ok(()) | 199 | Ok(()) |
| 193 | } | 200 | } |