BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / shell.rs

shell.rs

fix(presence): review findings
metis Daniel Däschle · pushed by metis · 7 weeks ago
a755adcc History
shell.rs 27.3 KiB Download Raw
1use std::sync::Arc;
2
3use gpui_kit::component::{h_flex, v_flex};
4use gpui_kit::*;
5
6use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
7use super::call_mini::render_call_mini;
8use super::call_stage::render_stage_overlay;
9use super::call_view::render_call_view;
10use super::conversation::{ConversationView, ReplyToHovered};
11use super::dialog_overlay::render_task_dialog;
12use super::forward_dialog::{ForwardDialog, ForwardDialogEvent};
13use super::image_viewer::{ImageViewer, ImageViewerEvent};
14use super::profile_card::{ProfileCard, ProfileCardEvent};
15use super::rail::RailView;
16use super::saved_panel::{SavedPanel, SavedPanelEvent};
17use super::shortcuts::{
18 AcceptCall, DeclineCall, HangUpCall, NextConversation, OpenActivity, OpenChannelsTab,
19 OpenCallsTab, OpenChatsTab, OpenSaved, PreviousConversation, Scope, ShowShortcuts, ToggleCallCamera,
20 ToggleCallShare,
21};
22use super::shortcuts_dialog::{ShortcutsDialog, ShortcutsDialogEvent};
23use super::sidebar::{SIDEBAR_WIDTH, SidebarView};
24use super::status_bar::render_status_bar;
25use super::status_menu::own_status_button;
26use super::status_message_dialog::{StatusMessageDialog, StatusMessageDialogEvent};
27use super::switcher::{Switcher, SwitcherEvent, candidates_from};
28use super::title_bar::render_title_bar;
29use crate::activity::ActivityCenter;
30use crate::app_state::{AppEvent, AppState, Selection};
31use crate::call::{CallMedia, CallWindows};
32use crate::embedded_web::{Overlays, RootFocus};
33use crate::notice::NoticeAction;
34use crate::user_activity::{self, UserInput};
35use crate::notify::{NotificationCenter, selection_for};
36use crate::sidebar_model::Step;
37use crate::theme;
38use crate::updater::{self, IdleInputs, UpdateStatus};
39
40actions!(teams, [OpenSwitcher, NewChat, ToggleCallMute]);
41
42pub fn bind_keys(cx: &mut App) {
43 super::composer::bind_keys(cx);
44 super::shortcuts::bind_scopes(cx, &[Scope::Global, Scope::OutsideComposer, Scope::GlobalOverTextFields]);
45}
46
47#[derive(Debug, Clone, Copy)]
48pub enum OpenTarget {
49 Chat(usize),
50 Channel(usize),
51}
52
53#[derive(Default)]
54pub struct Startup {
55 pub switcher_query: Option<String>,
56 pub composer_text: Option<String>,
57 pub reply_to_last: bool,
58}
59
60pub const ISLAND_GAP: f32 = 6.;
61
62pub struct UserInputHandle(pub Arc<UserInput>);
63
64impl Global for UserInputHandle {}
65
66pub struct AppShell {
67 state: Entity<AppState>,
68 rail: Entity<RailView>,
69 sidebar: Entity<SidebarView>,
70 conversation: Entity<ConversationView>,
71 call_chat: Option<(String, Entity<ConversationView>)>,
72 switcher: Option<Entity<Switcher>>,
73 notifications: Entity<NotificationCenter>,
74 _call_windows: Entity<CallWindows>,
75 forward_dialog: Option<Entity<ForwardDialog>>,
76 image_viewer: Option<Entity<ImageViewer>>,
77 status_dialog: Option<Entity<StatusMessageDialog>>,
78 shortcuts_dialog: Option<Entity<ShortcutsDialog>>,
79 profile_card: Option<Entity<ProfileCard>>,
80 focus_handle: FocusHandle,
81 open_target: Option<OpenTarget>,
82 update: UpdateStatus,
83 user_input: Arc<UserInput>,
84 _subscription: Subscription,
85 _call_media_observation: Subscription,
86 _panel_subscriptions: [Subscription; 2],
87 _escape_observation: Subscription,
88 _activation_observation: Subscription,
89}
90
91impl AppShell {
92 fn sync_call_chat(&mut self, thread: Option<String>, window: &mut Window, cx: &mut Context<Self>) {
93 match (thread, &self.call_chat) {
94 (Some(wanted), Some((open, _))) if &wanted == open => {}
95 (Some(wanted), _) => {
96 let app = self.state.clone();
97 let selection = Selection::Chat(wanted.clone());
98 let view = cx.new(|cx| ConversationView::pinned_to(app, selection, window, cx));
99 self.call_chat = Some((wanted, view));
100 }
101 (None, _) => self.call_chat = None,
102 }
103 }
104
105 pub fn new(
106 state: Entity<AppState>,
107 open_target: Option<OpenTarget>,
108 startup: Startup,
109 window: &mut Window,
110 cx: &mut Context<Self>,
111 ) -> Self {
112 let call_media = cx.new(|_| CallMedia);
113 state.update(cx, |state, _| state.call_media = Some(call_media.clone()));
114 let call_media_observation = cx.observe(&call_media, |_, _, cx| cx.notify());
115 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
116 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
117 let saved_panel = cx.new(|cx| SavedPanel::new(state.clone(), cx));
118 let panel_subscriptions = [
119 cx.subscribe(&activity_panel, |this, _, event: &ActivityPanelEvent, cx| match event {
120 ActivityPanelEvent::OpenSettings => this
121 .notifications
122 .update(cx, |center, cx| center.open_settings(cx)),
123 ActivityPanelEvent::Open {
124 conversation_id,
125 message_id,
126 } => this.open_message(conversation_id, message_id, cx),
127 }),
128 cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {
129 let SavedPanelEvent::Open {
130 conversation_id,
131 message_id,
132 } = event;
133 this.open_message(conversation_id, message_id, cx);
134 }),
135 ];
136 let sidebar = cx.new(|cx| SidebarView::new(state.clone(), activity_panel, saved_panel, cx));
137 let rail = cx.new(|cx| RailView::new(state.clone(), activity.clone(), sidebar.clone(), cx));
138 let conversation = cx.new(|cx| ConversationView::new(state.clone(), window, cx));
139 let subscription =
140 cx.subscribe_in(&state, window, |this, _, event: &AppEvent, window, cx| {
141 if matches!(event, AppEvent::Sidebar | AppEvent::Status) {
142 this.apply_open_target(cx);
143 }
144 if matches!(event, AppEvent::Forward) {
145 this.open_forward_dialog(window, cx);
146 }
147 if matches!(event, AppEvent::ImageViewer) {
148 this.open_image_viewer(window, cx);
149 }
150 if matches!(event, AppEvent::StatusMessage) {
151 this.open_status_dialog(window, cx);
152 }
153 if matches!(event, AppEvent::NotificationSettings) {
154 this.notifications
155 .update(cx, |center, cx| center.open_settings(cx));
156 }
157 if matches!(event, AppEvent::Profile) {
158 this.open_profile_card(window, cx);
159 }
160 cx.notify();
161 });
162 let focus_handle = cx.focus_handle();
163 window.focus(&focus_handle, cx);
164 cx.set_global(RootFocus(focus_handle.clone()));
165 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
166 let call_windows = cx.new(|cx| CallWindows::new(state.clone(), window, cx));
167 let user_input = cx.global::<UserInputHandle>().0.clone();
168 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
169 this.user_input.touch();
170 if event.keystroke.key == "escape" {
171 this.state.update(cx, |state, cx| state.leave_stage_fullscreen(cx));
172 }
173 });
174 let activation_observation = cx.observe_window_activation(window, |this, window, cx| {
175 if window.is_window_active() {
176 this.state.update(cx, |state, cx| state.refresh_calendar(cx));
177 }
178 });
179 let closing = notifications.clone();
180 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
181 let mut shell = AppShell {
182 state,
183 rail,
184 sidebar,
185 conversation,
186 call_chat: None,
187 switcher: None,
188 notifications,
189 _call_windows: call_windows,
190 forward_dialog: None,
191 image_viewer: None,
192 status_dialog: None,
193 shortcuts_dialog: None,
194 profile_card: None,
195 focus_handle,
196 open_target,
197 update: UpdateStatus::UpToDate,
198 user_input,
199 _subscription: subscription,
200 _call_media_observation: call_media_observation,
201 _panel_subscriptions: panel_subscriptions,
202 _escape_observation: escape_observation,
203 _activation_observation: activation_observation,
204 };
205 shell.apply_open_target(cx);
206 let Startup {
207 switcher_query,
208 composer_text,
209 reply_to_last,
210 } = startup;
211 if let Some(query) = switcher_query {
212 shell.toggle_switcher(&query, window, cx);
213 }
214 if composer_text.is_some() || reply_to_last {
215 cx.defer_in(window, move |this, window, cx| {
216 this.conversation.update(cx, |conversation, cx| {
217 if reply_to_last {
218 conversation.reply_to_latest_from_others(window, cx);
219 }
220 if let Some(text) = composer_text {
221 conversation.set_composer_text(&text, window, cx);
222 }
223 });
224 });
225 }
226 #[cfg(windows)]
227 cx.spawn_in(window, async move |this, cx| {
228 loop {
229 cx.background_executor().timer(updater::POLL_INTERVAL).await;
230 if this
231 .update_in(cx, |this, window, cx| this.poll_update(window, cx))
232 .is_err()
233 {
234 break;
235 }
236 }
237 })
238 .detach();
239 shell
240 }
241
242 #[cfg_attr(not(windows), allow(dead_code))]
243 fn poll_update(&mut self, window: &mut Window, cx: &mut Context<Self>) {
244 if matches!(self.update, UpdateStatus::Failed(_) | UpdateStatus::Installing) {
245 return;
246 }
247 let Some(paths) = updater::current_paths() else {
248 return;
249 };
250 if self.update == UpdateStatus::UpToDate {
251 if !updater::check(&paths) {
252 return;
253 }
254 self.update = UpdateStatus::Ready;
255 let update_exe = paths.update_exe.clone();
256 cx.background_spawn(async move { updater::prescan(&update_exe) })
257 .detach();
258 }
259 let conversation = self.conversation.read(cx);
260 let idle = updater::is_idle(IdleInputs {
261 window_active: window.is_window_active(),
262 composer_empty: conversation.composer_is_empty(cx),
263 send_in_flight: conversation.send_in_flight(),
264 });
265 if idle {
266 self.restart_into_update(cx);
267 }
268 cx.notify();
269 }
270
271 fn restart_into_update(&mut self, cx: &mut Context<Self>) {
272 if self.update == UpdateStatus::Installing {
273 return;
274 }
275 let Some(paths) = updater::current_paths() else {
276 return;
277 };
278 self.update = UpdateStatus::Installing;
279 cx.notify();
280 cx.spawn(async move |this, cx| {
281 let result = cx
282 .background_spawn(async move { updater::install_and_relaunch(&paths) })
283 .await;
284 let _ = this.update(cx, |this, cx| {
285 match result {
286 Ok(()) => cx.quit(),
287 Err(message) => this.update = UpdateStatus::Failed(message),
288 }
289 cx.notify();
290 });
291 })
292 .detach();
293 }
294
295 fn apply_open_target(&mut self, cx: &mut Context<Self>) {
296 let Some(target) = self.open_target else {
297 return;
298 };
299 let sidebar = &self.state.read(cx).sidebar;
300 let selection = match target {
301 OpenTarget::Chat(index) => sidebar
302 .chats
303 .get(index)
304 .map(|chat| Selection::Chat(chat.id.clone())),
305 OpenTarget::Channel(index) => sidebar
306 .teams
307 .iter()
308 .flat_map(|team| team.channels.iter())
309 .nth(index)
310 .map(|channel| Selection::Channel(channel.id.clone())),
311 };
312 if let Some(selection) = selection {
313 self.open_target = None;
314 self.state
315 .update(cx, |state, cx| state.select(selection, cx));
316 }
317 }
318
319 fn toggle_switcher(
320 &mut self,
321 initial_query: &str,
322 window: &mut Window,
323 cx: &mut Context<Self>,
324 ) {
325 if self.switcher.take().is_some() {
326 self.restore_focus(window, cx);
327 cx.notify();
328 return;
329 }
330 self.close_image_viewer(window, cx);
331 let candidates = candidates_from(self.state.read(cx));
332 let app = self.state.clone();
333 let switcher = cx.new(|cx| Switcher::new(app, candidates, initial_query, window, cx));
334 cx.subscribe_in(
335 &switcher,
336 window,
337 |this, _, event: &SwitcherEvent, window, cx| {
338 match event {
339 SwitcherEvent::Pick(selection) => {
340 let selection = selection.clone();
341 this.state
342 .update(cx, |state, cx| state.select(selection, cx));
343 }
344 SwitcherEvent::PickMessage {
345 selection,
346 message_id,
347 } => {
348 let (selection, message_id) = (selection.clone(), message_id.clone());
349 this.state.update(cx, |state, cx| {
350 state.jump_to_message(selection, message_id, cx)
351 });
352 }
353 SwitcherEvent::Close => {}
354 }
355 this.switcher = None;
356 this.restore_focus(window, cx);
357 cx.notify();
358 },
359 )
360 .detach();
361 self.switcher = Some(switcher);
362 cx.notify();
363 }
364
365 fn open_message(&mut self, conversation_id: &str, message_id: &str, cx: &mut Context<Self>) {
366 let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {
367 return;
368 };
369 let message_id = message_id.to_owned();
370 self.state.update(cx, |state, cx| {
371 if message_id.is_empty() {
372 state.select(selection, cx)
373 } else {
374 state.jump_to_message(selection, message_id, cx)
375 }
376 });
377 }
378
379 fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
380 if !self
381 .state
382 .update(cx, |state, _| state.take_status_message_request())
383 {
384 return;
385 }
386 self.close_image_viewer(window, cx);
387 self.switcher = None;
388 let app = self.state.clone();
389 let dialog = cx.new(|cx| StatusMessageDialog::new(app, window, cx));
390 cx.subscribe_in(
391 &dialog,
392 window,
393 |this, _, _: &StatusMessageDialogEvent, window, cx| {
394 this.status_dialog = None;
395 this.restore_focus(window, cx);
396 cx.notify();
397 },
398 )
399 .detach();
400 self.status_dialog = Some(dialog);
401 cx.notify();
402 }
403
404 fn toggle_shortcuts_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
405 if self.shortcuts_dialog.take().is_some() {
406 self.restore_focus(window, cx);
407 cx.notify();
408 return;
409 }
410 self.close_image_viewer(window, cx);
411 self.switcher = None;
412 let dialog = cx.new(|cx| ShortcutsDialog::new(window, cx));
413 cx.subscribe_in(
414 &dialog,
415 window,
416 |this, _, _: &ShortcutsDialogEvent, window, cx| {
417 this.shortcuts_dialog = None;
418 this.restore_focus(window, cx);
419 cx.notify();
420 },
421 )
422 .detach();
423 self.shortcuts_dialog = Some(dialog);
424 cx.notify();
425 }
426
427 fn open_profile_card(&mut self, window: &mut Window, cx: &mut Context<Self>) {
428 let Some(request) = self
429 .state
430 .update(cx, |state, _| state.take_profile_request())
431 else {
432 return;
433 };
434 self.close_image_viewer(window, cx);
435 if let Some(card) = &self.profile_card {
436 card.update(cx, |card, cx| {
437 card.move_to(request.user_id, request.anchor, cx)
438 });
439 return;
440 }
441 let app = self.state.clone();
442 let card = cx.new(|cx| ProfileCard::new(app, request.user_id, request.anchor, window, cx));
443 cx.subscribe_in(
444 &card,
445 window,
446 |this, _, _: &ProfileCardEvent, window, cx| {
447 this.profile_card = None;
448 this.restore_focus(window, cx);
449 cx.notify();
450 },
451 )
452 .detach();
453 self.profile_card = Some(card);
454 cx.notify();
455 }
456
457 fn open_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
458 let Some(request) = self
459 .state
460 .update(cx, |state, _| state.take_image_viewer_request())
461 else {
462 return;
463 };
464 self.switcher = None;
465 let app = self.state.clone();
466 let viewer = cx.new(|cx| ImageViewer::new(app, request, window, cx));
467 cx.subscribe_in(
468 &viewer,
469 window,
470 |this, _, _: &ImageViewerEvent, window, cx| {
471 this.image_viewer = None;
472 window.focus(&this.focus_handle, cx);
473 cx.notify();
474 },
475 )
476 .detach();
477 self.image_viewer = Some(viewer);
478 cx.notify();
479 }
480
481 fn close_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
482 if self.image_viewer.take().is_some() {
483 window.focus(&self.focus_handle, cx);
484 cx.notify();
485 }
486 }
487
488 fn restore_focus(&self, window: &mut Window, cx: &mut Context<Self>) {
489 match &self.image_viewer {
490 Some(viewer) => {
491 let handle = viewer.read(cx).focus_handle();
492 window.focus(&handle, cx)
493 }
494 None => window.focus(&self.focus_handle, cx),
495 }
496 }
497
498 fn open_forward_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
499 let Some(source) = self
500 .state
501 .update(cx, |state, _| state.take_forward_request())
502 else {
503 return;
504 };
505 self.switcher = None;
506 let candidates = candidates_from(self.state.read(cx));
507 let app = self.state.clone();
508 let dialog = cx.new(|cx| ForwardDialog::new(app, source, candidates, window, cx));
509 cx.subscribe_in(
510 &dialog,
511 window,
512 |this, _, event: &ForwardDialogEvent, window, cx| {
513 this.forward_dialog = None;
514 this.restore_focus(window, cx);
515 if let ForwardDialogEvent::Sent { target, title } = event {
516 let target = target.clone();
517 let open = NoticeAction::new("Open", move |state, cx| {
518 state.select(target.clone(), cx)
519 });
520 this.state.update(cx, |state, cx| {
521 state.raise_notice(format!("Forwarded to {title}"), Some(open), cx)
522 });
523 }
524 cx.notify();
525 },
526 )
527 .detach();
528 self.forward_dialog = Some(dialog);
529 cx.notify();
530 }
531}
532
533impl AppShell {
534 fn islands(&self, call_view: Option<AnyElement>) -> impl IntoElement {
535 h_flex()
536 .flex_1()
537 .min_h_0()
538 .w_full()
539 .gap(px(ISLAND_GAP))
540 .pr(px(ISLAND_GAP))
541 .py(px(ISLAND_GAP))
542 .child(
543 h_flex()
544 .h_full()
545 .flex_none()
546 .child(self.rail.clone())
547 .child(
548 self.sidebar
549 .clone()
550 .cached(StyleRefinement::default().w(px(SIDEBAR_WIDTH)).h_full().flex_none()),
551 ),
552 )
553 .child(match call_view {
554 Some(call_view) => call_view,
555 None => self
556 .conversation
557 .clone()
558 .cached(
559 StyleRefinement::default()
560 .flex_1()
561 .min_w_0()
562 .h_full()
563 .rounded(px(10.))
564 .bg(theme::surface())
565 .overflow_hidden(),
566 )
567 .into_any_element(),
568 })
569 }
570}
571
572impl Render for AppShell {
573 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
574 if let Some(dialog) = self
575 .state
576 .read(cx)
577 .task_dialog
578 .as_ref()
579 .map(|dialog| (dialog.scope.clone(), dialog.card.clone()))
580 {
581 self.state.update(cx, |state, cx| {
582 state.ensure_card_inputs(&dialog.0, &dialog.1, window, cx)
583 });
584 }
585 if let Some(me) = self.state.read(cx).directory.me.clone() {
586 let app = self.state.clone();
587 cx.defer(move |cx| {
588 app.update(cx, |state, cx| {
589 state.request_avatars(vec![me.user_id.clone()], cx);
590 state.request_presence(vec![me.user_id], cx);
591 });
592 });
593 }
594 let panels = self.switcher.is_some()
595 || self.forward_dialog.is_some()
596 || self.image_viewer.is_some()
597 || self.status_dialog.is_some()
598 || self.shortcuts_dialog.is_some()
599 || self.profile_card.is_some()
600 || {
601 let state = self.state.read(cx);
602 state.task_dialog.is_some() || state.status_menu_open
603 };
604 Overlays::update(cx, |overlays| overlays.panels = panels);
605 let chat_thread = self.state.read(cx).call_chat_thread();
606 self.sync_call_chat(chat_thread, window, cx);
607 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone());
608 let state = self.state.read(cx);
609 let call_view = render_call_view(&self.state, state, chat_panel).filter(|_| state.viewing_call());
610 let call_mini = render_call_mini(&self.state, state);
611 let stage_overlay = render_stage_overlay(&self.state, state);
612 let status = render_status_bar(
613 state,
614 &self.update,
615 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
616 cx.listener(|this, _, _, cx| {
617 this.state
618 .update(cx, |state, cx| state.run_notice_action(cx))
619 }),
620 );
621 let title_bar = render_title_bar(
622 own_status_button(&self.state, state),
623 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
624 );
625 div()
626 .id("app-shell")
627 .key_context("AppShell")
628 .track_focus(&self.focus_handle)
629 .on_action(cx.listener(|this, _: &OpenSwitcher, window, cx| {
630 this.toggle_switcher("", window, cx);
631 }))
632 .on_action(cx.listener(|this, _: &NewChat, window, cx| {
633 this.close_image_viewer(window, cx);
634 this.state.update(cx, |state, cx| state.start_new_chat(cx));
635 }))
636 .on_action(cx.listener(|this, _: &ToggleCallMute, _, cx| {
637 this.state.update(cx, |state, cx| state.toggle_call_mute(cx));
638 }))
639 .on_action(cx.listener(|this, _: &ShowShortcuts, window, cx| {
640 this.toggle_shortcuts_dialog(window, cx);
641 }))
642 .on_action(cx.listener(|this, _: &OpenActivity, window, cx| {
643 this.close_image_viewer(window, cx);
644 this.sidebar.update(cx, |sidebar, cx| sidebar.show_activity(cx));
645 }))
646 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
647 this.close_image_viewer(window, cx);
648 this.sidebar.update(cx, |sidebar, cx| sidebar.show_saved(cx));
649 }))
650 .on_action(cx.listener(|this, _: &OpenChatsTab, window, cx| {
651 this.close_image_viewer(window, cx);
652 this.sidebar.update(cx, |sidebar, cx| sidebar.show_chats(cx));
653 }))
654 .on_action(cx.listener(|this, _: &OpenChannelsTab, window, cx| {
655 this.close_image_viewer(window, cx);
656 this.sidebar.update(cx, |sidebar, cx| sidebar.show_channels(cx));
657 }))
658 .on_action(cx.listener(|this, _: &OpenCallsTab, window, cx| {
659 this.close_image_viewer(window, cx);
660 this.sidebar.update(cx, |sidebar, cx| sidebar.show_calls(cx));
661 }))
662 .on_action(cx.listener(|this, _: &PreviousConversation, window, cx| {
663 this.close_image_viewer(window, cx);
664 this.sidebar
665 .update(cx, |sidebar, cx| sidebar.select_adjacent(Step::Previous, cx));
666 }))
667 .on_action(cx.listener(|this, _: &NextConversation, window, cx| {
668 this.close_image_viewer(window, cx);
669 this.sidebar
670 .update(cx, |sidebar, cx| sidebar.select_adjacent(Step::Next, cx));
671 }))
672 .on_action(cx.listener(|this, _: &AcceptCall, _, cx| {
673 this.state.update(cx, |state, cx| state.accept_ringing_call(cx));
674 }))
675 .on_action(cx.listener(|this, _: &DeclineCall, _, cx| {
676 this.state.update(cx, |state, cx| state.decline_ringing_call(cx));
677 }))
678 .on_action(cx.listener(|this, _: &HangUpCall, _, cx| {
679 this.state.update(cx, |state, cx| state.leave_call(cx));
680 }))
681 .on_action(cx.listener(|this, _: &ToggleCallCamera, _, cx| {
682 this.state.update(cx, |state, cx| state.toggle_call_camera(cx));
683 }))
684 .on_action(cx.listener(|this, _: &ToggleCallShare, _, cx| {
685 this.state.update(cx, |state, cx| state.toggle_call_share(cx));
686 }))
687 .on_action(cx.listener(|this, _: &ReplyToHovered, window, cx| {
688 this.close_image_viewer(window, cx);
689 this.conversation.update(cx, |conversation, cx| {
690 conversation.reply_to_hovered(window, cx)
691 });
692 }))
693 .relative()
694 .size_full()
695 .bg(theme::background())
696 .text_color(theme::text())
697 .text_size(px(14.))
698 .child(crate::frame_log::probe("first"))
699 .child(user_activity::input_probe(self.user_input.clone()))
700 .child(
701 v_flex()
702 .size_full()
703 .child(title_bar)
704 .child(self.islands(call_view))
705 .child(status),
706 )
707 .children(call_mini)
708 .children(stage_overlay)
709 .children(self.image_viewer.clone())
710 .children(self.switcher.clone())
711 .children(render_task_dialog(self.state.read(cx), cx))
712 .children(self.forward_dialog.clone())
713 .children(self.status_dialog.clone())
714 .children(self.shortcuts_dialog.clone())
715 .children(self.profile_card.clone())
716 .child(crate::frame_log::probe("last"))
717 }
718}