BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-state / src / call / end_actions.rs

end_actions.rs

end_actions.rs 2.6 KiB Download Raw
1use gpui_kit::*;
2
3use super::end_screen::{CallEndScreen, EndCause};
4use super::model::{CallKind, PendingMove};
5use crate::app_state::{AppEvent, AppState};
6
7const DEMO_MEETING_THREAD: &str = "demo-chat-meeting-standup";
8
9impl AppState {
10 pub fn dismiss_call_end(&mut self, cx: &mut Context<Self>) {
11 if self.call_end.take().is_some() {
12 cx.emit(AppEvent::Call);
13 cx.notify();
14 }
15 }
16
17 pub fn retry_call_end(&mut self, cx: &mut Context<Self>) {
18 let Some(screen) = self.call_end.take() else {
19 return;
20 };
21 cx.emit(AppEvent::Call);
22 cx.notify();
23 match (screen.kind, screen.meeting_target, screen.conversation_id) {
24 (CallKind::Test, _, _) => self.start_test_call(cx),
25 (CallKind::Meeting, Some(target), _) => self.join_moved_call(
26 PendingMove {
27 target,
28 title: screen.title,
29 breakout: None,
30 },
31 cx,
32 ),
33 (CallKind::Group, _, Some(conversation_id))
34 if self.running_meeting(&conversation_id).is_some() =>
35 {
36 self.join_meeting_call(&conversation_id, cx)
37 }
38 (CallKind::Direct | CallKind::Group, _, Some(conversation_id)) => {
39 self.start_chat_call(&conversation_id, cx)
40 }
41 _ => {}
42 }
43 }
44
45 pub fn demo_call_end(&mut self, cause: EndCause, cx: &mut Context<Self>) {
46 let screen = match cause {
47 EndCause::Removed => CallEndScreen {
48 cause,
49 kind: CallKind::Meeting,
50 title: "Standup".to_owned(),
51 conversation_id: Some(DEMO_MEETING_THREAD.to_owned()),
52 meeting_target: Some(calling::MeetingTarget {
53 thread_id: DEMO_MEETING_THREAD.to_owned(),
54 tenant_id: "demo-tenant".to_owned(),
55 organizer_id: "demo-me".to_owned(),
56 meeting_data: None,
57 }),
58 peer: None,
59 },
60 EndCause::Dropped => CallEndScreen {
61 cause,
62 kind: CallKind::Direct,
63 title: "Mara Lindqvist".to_owned(),
64 conversation_id: Some("demo-chat-mara".to_owned()),
65 meeting_target: None,
66 peer: Some(super::end_screen::EndPeer {
67 user_id: Some("demo-mara".to_owned()),
68 name: "Mara Lindqvist".to_owned(),
69 }),
70 },
71 };
72 self.call_end = Some(screen);
73 cx.emit(AppEvent::Call);
74 cx.notify();
75 }
76}