BlueGit

ict rusty-teams

feat(meeting-chat): Join in every meeting chat header like Teams

- without a running call, Join reads the chat's onlineMeetingInfo.joinWebUrl and opens the prejoin
- running meetings keep the green Join

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-09 · 3 weeks ago

Hash
6e9901393bd6dd296453ea5334d59d441a7a49c9
Parent
15e7d377
5 files changed +57 −10
crates/app-state/src/call/join.rs +23 −0
@@ -106,6 +106,29 @@ impl AppState {
106 106 .detach();
107 107 }
108 108
109 /// Teams offers Join in every meeting chat; without a running call the meeting starts from its join link.
110 pub fn join_chat_meeting(&mut self, chat_id: &str, cx: &mut Context<Self>) {
111 if self.call.is_some() || self.running_meeting(chat_id).is_some() || self.mode.demo {
112 self.join_meeting_call(chat_id, cx);
113 return;
114 }
115 let Some(engine) = self.engine.clone() else {
116 self.raise_notice(NOT_CONNECTED_NOTICE.to_owned(), None, cx);
117 return;
118 };
119 let chat_id = chat_id.to_owned();
120 let receiver = runtime::spawn(async move { engine.meeting_join_url(&chat_id).await });
121 cx.spawn(async move |this, cx| {
122 let url = receiver.await.ok().and_then(Result::ok).flatten();
123 this.update(cx, |state, cx| match url {
124 Some(url) => state.join_link(&url, JoinMode::Prejoin, cx),
125 None => state.raise_notice(MEETING_UNAVAILABLE_NOTICE.to_owned(), None, cx),
126 })
127 .ok();
128 })
129 .detach();
130 }
131
109 132 pub fn join_meeting_link(&mut self, text: &str, cx: &mut Context<Self>) {
110 133 self.join_link(text, JoinMode::Prejoin, cx);
111 134 }
@@ -106,6 +106,29 @@ impl AppState {
106 .detach();
106 .detach();
107 }
107 }
108
108
109 /// Teams offers Join in every meeting chat; without a running call the meeting starts from its join link.
110 pub fn join_chat_meeting(&mut self, chat_id: &str, cx: &mut Context<Self>) {
111 if self.call.is_some() || self.running_meeting(chat_id).is_some() || self.mode.demo {
112 self.join_meeting_call(chat_id, cx);
113 return;
114 }
115 let Some(engine) = self.engine.clone() else {
116 self.raise_notice(NOT_CONNECTED_NOTICE.to_owned(), None, cx);
117 return;
118 };
119 let chat_id = chat_id.to_owned();
120 let receiver = runtime::spawn(async move { engine.meeting_join_url(&chat_id).await });
121 cx.spawn(async move |this, cx| {
122 let url = receiver.await.ok().and_then(Result::ok).flatten();
123 this.update(cx, |state, cx| match url {
124 Some(url) => state.join_link(&url, JoinMode::Prejoin, cx),
125 None => state.raise_notice(MEETING_UNAVAILABLE_NOTICE.to_owned(), None, cx),
126 })
127 .ok();
128 })
129 .detach();
130 }
131
109 pub fn join_meeting_link(&mut self, text: &str, cx: &mut Context<Self>) {
132 pub fn join_meeting_link(&mut self, text: &str, cx: &mut Context<Self>) {
110 self.join_link(text, JoinMode::Prejoin, cx);
133 self.join_link(text, JoinMode::Prejoin, cx);
111 }
134 }
crates/app/src/views/call_controls.rs +17 −9
@@ -25,6 +25,7 @@ const AUDIO_CALL_LABEL: &str = "Audio call";
25 25 const CALL_OPTIONS_LABEL: &str = "Call options";
26 26 const MEET_NOW_LABEL: &str = "Meet now";
27 27 const GROUP_KIND: &str = "group";
28 const MEETING_KIND: &str = "meeting";
28 29
29 30 pub fn header_call_controls(
30 31 app: &Entity<AppState>,
@@ -34,9 +35,20 @@ pub fn header_call_controls(
34 35 ) -> Vec<AnyElement> {
35 36 let conversation_id = selection.conversation_id().to_owned();
36 37 let mut controls = Vec::new();
37 if state.running_meeting(&conversation_id).is_some() {
38 let chat = match selection {
39 Selection::Chat(chat_id) => state.sidebar.chats.iter().find(|chat| &chat.id == chat_id),
40 Selection::Channel(_) => None,
41 };
42 let running = state.running_meeting(&conversation_id).is_some();
43 let meeting_chat = chat.is_some_and(|chat| chat.kind.eq_ignore_ascii_case(MEETING_KIND));
44 if running || meeting_chat {
38 45 let join_app = app.clone();
39 46 let join_id = conversation_id.clone();
47 let (background, foreground) = if running {
48 (theme::green(), theme::white())
49 } else {
50 (theme::accent(), theme::on_accent())
51 };
40 52 controls.push(
41 53 h_flex()
42 54 .id("header-join")
@@ -46,24 +58,20 @@ pub fn header_call_controls(
46 58 .flex_none()
47 59 .items_center()
48 60 .rounded_full()
49 .bg(theme::green())
50 .text_color(theme::white())
61 .bg(background)
62 .text_color(foreground)
51 63 .text_size(px(13.))
52 64 .font_weight(FontWeight::SEMIBOLD)
53 65 .cursor_pointer()
54 66 .hover(|button| button.opacity(0.85))
55 .child(icon(IconName::Phone, 14., theme::white()))
67 .when(running, |button| button.child(icon(IconName::Phone, 14., foreground)))
56 68 .child("Join")
57 69 .on_click(move |_, _, cx| {
58 join_app.update(cx, |state, cx| state.join_meeting_call(&join_id, cx));
70 join_app.update(cx, |state, cx| state.join_chat_meeting(&join_id, cx));
59 71 })
60 72 .into_any_element(),
61 73 );
62 74 }
63 let chat = match selection {
64 Selection::Chat(chat_id) => state.sidebar.chats.iter().find(|chat| &chat.id == chat_id),
65 Selection::Channel(_) => None,
66 };
67 75 let callable = chat.is_some_and(|chat| {
68 76 is_echo_chat(chat) || plan_for_chat(chat, state.directory.me.as_ref()).is_some()
69 77 });
@@ -25,6 +25,7 @@ const AUDIO_CALL_LABEL: &str = "Audio call";
25const CALL_OPTIONS_LABEL: &str = "Call options";
25const CALL_OPTIONS_LABEL: &str = "Call options";
26const MEET_NOW_LABEL: &str = "Meet now";
26const MEET_NOW_LABEL: &str = "Meet now";
27const GROUP_KIND: &str = "group";
27const GROUP_KIND: &str = "group";
28const MEETING_KIND: &str = "meeting";
28
29
29pub fn header_call_controls(
30pub fn header_call_controls(
30 app: &Entity<AppState>,
31 app: &Entity<AppState>,
@@ -34,9 +35,20 @@ pub fn header_call_controls(
34) -> Vec<AnyElement> {
35) -> Vec<AnyElement> {
35 let conversation_id = selection.conversation_id().to_owned();
36 let conversation_id = selection.conversation_id().to_owned();
36 let mut controls = Vec::new();
37 let mut controls = Vec::new();
37 if state.running_meeting(&conversation_id).is_some() {
38 let chat = match selection {
39 Selection::Chat(chat_id) => state.sidebar.chats.iter().find(|chat| &chat.id == chat_id),
40 Selection::Channel(_) => None,
41 };
42 let running = state.running_meeting(&conversation_id).is_some();
43 let meeting_chat = chat.is_some_and(|chat| chat.kind.eq_ignore_ascii_case(MEETING_KIND));
44 if running || meeting_chat {
38 let join_app = app.clone();
45 let join_app = app.clone();
39 let join_id = conversation_id.clone();
46 let join_id = conversation_id.clone();
47 let (background, foreground) = if running {
48 (theme::green(), theme::white())
49 } else {
50 (theme::accent(), theme::on_accent())
51 };
40 controls.push(
52 controls.push(
41 h_flex()
53 h_flex()
42 .id("header-join")
54 .id("header-join")
@@ -46,24 +58,20 @@ pub fn header_call_controls(
46 .flex_none()
58 .flex_none()
47 .items_center()
59 .items_center()
48 .rounded_full()
60 .rounded_full()
49 .bg(theme::green())
61 .bg(background)
50 .text_color(theme::white())
62 .text_color(foreground)
51 .text_size(px(13.))
63 .text_size(px(13.))
52 .font_weight(FontWeight::SEMIBOLD)
64 .font_weight(FontWeight::SEMIBOLD)
53 .cursor_pointer()
65 .cursor_pointer()
54 .hover(|button| button.opacity(0.85))
66 .hover(|button| button.opacity(0.85))
55 .child(icon(IconName::Phone, 14., theme::white()))
67 .when(running, |button| button.child(icon(IconName::Phone, 14., foreground)))
56 .child("Join")
68 .child("Join")
57 .on_click(move |_, _, cx| {
69 .on_click(move |_, _, cx| {
58 join_app.update(cx, |state, cx| state.join_meeting_call(&join_id, cx));
70 join_app.update(cx, |state, cx| state.join_chat_meeting(&join_id, cx));
59 })
71 })
60 .into_any_element(),
72 .into_any_element(),
61 );
73 );
62 }
74 }
63 let chat = match selection {
64 Selection::Chat(chat_id) => state.sidebar.chats.iter().find(|chat| &chat.id == chat_id),
65 Selection::Channel(_) => None,
66 };
67 let callable = chat.is_some_and(|chat| {
75 let callable = chat.is_some_and(|chat| {
68 is_echo_chat(chat) || plan_for_chat(chat, state.directory.me.as_ref()).is_some()
76 is_echo_chat(chat) || plan_for_chat(chat, state.directory.me.as_ref()).is_some()
69 });
77 });
crates/core/src/engine.rs +8 −0
@@ -394,6 +394,14 @@ impl<R: Remote> SyncEngine<R> {
394 394 self.my_tenant_id_from(&any_chat_id).await
395 395 }
396 396
397 pub async fn meeting_join_url(&self, chat_id: &str) -> Result<Option<String>> {
398 let chat = self.remote.chat(chat_id).await?;
399 Ok(chat
400 .online_meeting_info
401 .and_then(|info| info.join_web_url)
402 .filter(|url| !url.is_empty()))
403 }
404
397 405 pub(crate) async fn resolve(&self, conversation_id: &str) -> Result<Conversation> {
398 406 match self.resolve_stored(conversation_id) {
399 407 Err(Error::UnknownConversation(_)) => self.fetch_unknown_chat(conversation_id).await,
@@ -394,6 +394,14 @@ impl<R: Remote> SyncEngine<R> {
394 self.my_tenant_id_from(&any_chat_id).await
394 self.my_tenant_id_from(&any_chat_id).await
395 }
395 }
396
396
397 pub async fn meeting_join_url(&self, chat_id: &str) -> Result<Option<String>> {
398 let chat = self.remote.chat(chat_id).await?;
399 Ok(chat
400 .online_meeting_info
401 .and_then(|info| info.join_web_url)
402 .filter(|url| !url.is_empty()))
403 }
404
397 pub(crate) async fn resolve(&self, conversation_id: &str) -> Result<Conversation> {
405 pub(crate) async fn resolve(&self, conversation_id: &str) -> Result<Conversation> {
398 match self.resolve_stored(conversation_id) {
406 match self.resolve_stored(conversation_id) {
399 Err(Error::UnknownConversation(_)) => self.fetch_unknown_chat(conversation_id).await,
407 Err(Error::UnknownConversation(_)) => self.fetch_unknown_chat(conversation_id).await,
crates/graph/src/lib.rs +1 −1
@@ -22,7 +22,7 @@ pub use files::{
22 22 };
23 23 pub use library::DriveEntry;
24 24 pub use models::{
25 Attachment, Body, Channel, Chat, ChatViewpoint, Identity, Member, Mention, Message, Photo,
25 Attachment, Body, Channel, Chat, ChatViewpoint, Identity, Member, Mention, Message, OnlineMeetingInfo, Photo,
26 26 Presence, Reaction, Sender, Tag, Team, UNKNOWN_USER_NAME, User,
27 27 };
28 28 pub use outgoing::{
@@ -22,7 +22,7 @@ pub use files::{
22};
22};
23pub use library::DriveEntry;
23pub use library::DriveEntry;
24pub use models::{
24pub use models::{
25 Attachment, Body, Channel, Chat, ChatViewpoint, Identity, Member, Mention, Message, Photo,
25 Attachment, Body, Channel, Chat, ChatViewpoint, Identity, Member, Mention, Message, OnlineMeetingInfo, Photo,
26 Presence, Reaction, Sender, Tag, Team, UNKNOWN_USER_NAME, User,
26 Presence, Reaction, Sender, Tag, Team, UNKNOWN_USER_NAME, User,
27};
27};
28pub use outgoing::{
28pub use outgoing::{
crates/graph/src/models.rs +8 −0
@@ -166,6 +166,14 @@ pub struct Chat {
166 166 pub members: Vec<Member>,
167 167 pub last_message_preview: Option<Message>,
168 168 pub viewpoint: Option<ChatViewpoint>,
169 #[serde(default)]
170 pub online_meeting_info: Option<OnlineMeetingInfo>,
171 }
172
173 #[derive(Debug, Clone, Deserialize, PartialEq)]
174 #[serde(rename_all = "camelCase")]
175 pub struct OnlineMeetingInfo {
176 pub join_web_url: Option<String>,
169 177 }
170 178
171 179 impl Chat {
@@ -166,6 +166,14 @@ pub struct Chat {
166 pub members: Vec<Member>,
166 pub members: Vec<Member>,
167 pub last_message_preview: Option<Message>,
167 pub last_message_preview: Option<Message>,
168 pub viewpoint: Option<ChatViewpoint>,
168 pub viewpoint: Option<ChatViewpoint>,
169 #[serde(default)]
170 pub online_meeting_info: Option<OnlineMeetingInfo>,
171}
172
173#[derive(Debug, Clone, Deserialize, PartialEq)]
174#[serde(rename_all = "camelCase")]
175pub struct OnlineMeetingInfo {
176 pub join_web_url: Option<String>,
169}
177}
170
178
171impl Chat {
179impl Chat {