fix(app): no notification sound while in a call
Own presence activity InACall or InAConferenceCall sets in_call, which was always false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -333,6 +333,12 @@ pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
333
333
})
334
334
}
335
335
336
pub fn in_call(engine: &Engine, user_id: &str) -> bool {
337
engine
338
.presence(user_id)
339
.is_some_and(|presence| presence.in_call)
340
}
341
336
342
pub type Done = oneshot::Receiver<Result<(), String>>;
337
343
338
344
fn run<F>(future: F) -> Done
@@ -333,6 +333,12 @@ pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {333
})333
})334
}334
}335
335
336
pub fn in_call(engine: &Engine, user_id: &str) -> bool {337
engine338
.presence(user_id)339
.is_some_and(|presence| presence.in_call)340
}341
336
pub type Done = oneshot::Receiver<Result<(), String>>;342
pub type Done = oneshot::Receiver<Result<(), String>>;337
343
338
fn run<F>(future: F) -> Done344
fn run<F>(future: F) -> Done@@ -18,7 +18,7 @@ use super::stack::{ReplyState, SENT_DURATION, ToastModel, ToastStack};
18
18
use super::toast::{PillView, ToastView};
19
19
use super::settings_view::SettingsView;
20
20
use crate::app_state::{AppEvent, AppState, Selection};
21
use crate::data::{Directory, PresenceKind};
21
use crate::data::{self, Directory, PresenceKind};
22
22
use crate::runtime;
23
23
24
24
const TICK: Duration = Duration::from_millis(33);
@@ -188,11 +188,15 @@ impl NotificationCenter {
188
188
let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {
189
189
state.directory.presence_of(&me.user_id) == PresenceKind::DoNotDisturb
190
190
});
191
let in_call = match (state.engine.as_ref(), state.directory.me.as_ref()) {
192
(Some(engine), Some(me)) => data::in_call(engine, &me.user_id),
193
_ => false,
194
};
191
195
Environment {
192
196
chat_in_foreground: selected && self.main_window_active(cx),
193
197
system_quiet: platform::system_quiet(),
194
198
own_do_not_disturb,
195
in_call: false,
199
in_call,
196
200
}
197
201
}
198
202
@@ -18,7 +18,7 @@ use super::stack::{ReplyState, SENT_DURATION, ToastModel, ToastStack};18
use super::toast::{PillView, ToastView};18
use super::toast::{PillView, ToastView};19
use super::settings_view::SettingsView;19
use super::settings_view::SettingsView;20
use crate::app_state::{AppEvent, AppState, Selection};20
use crate::app_state::{AppEvent, AppState, Selection};21
use crate::data::{Directory, PresenceKind};21
use crate::data::{self, Directory, PresenceKind};22
use crate::runtime;22
use crate::runtime;23
23
24
const TICK: Duration = Duration::from_millis(33);24
const TICK: Duration = Duration::from_millis(33);@@ -188,11 +188,15 @@ impl NotificationCenter {188
let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {188
let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {189
state.directory.presence_of(&me.user_id) == PresenceKind::DoNotDisturb189
state.directory.presence_of(&me.user_id) == PresenceKind::DoNotDisturb190
});190
});191
let in_call = match (state.engine.as_ref(), state.directory.me.as_ref()) {192
(Some(engine), Some(me)) => data::in_call(engine, &me.user_id),193
_ => false,194
};191
Environment {195
Environment {192
chat_in_foreground: selected && self.main_window_active(cx),196
chat_in_foreground: selected && self.main_window_active(cx),193
system_quiet: platform::system_quiet(),197
system_quiet: platform::system_quiet(),194
own_do_not_disturb,198
own_do_not_disturb,195
in_call: false,199
in_call,196
}200
}197
}201
}198
202
@@ -31,6 +31,11 @@ impl Availability {
31
31
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32
32
pub struct Presence {
33
33
pub availability: Availability,
34
pub in_call: bool,
35
}
36
37
fn is_call_activity(activity: Option<&str>) -> bool {
38
matches!(activity, Some("InACall" | "InAConferenceCall"))
34
39
}
35
40
36
41
impl<R: Remote> SyncEngine<R> {
@@ -56,6 +61,7 @@ impl<R: Remote> SyncEngine<R> {
56
61
for entry in found {
57
62
let presence = Presence {
58
63
availability: Availability::from_service(&entry.availability),
64
in_call: is_call_activity(entry.activity.as_deref()),
59
65
};
60
66
changed |= known.insert(entry.user_id, presence) != Some(presence);
61
67
}
@@ -31,6 +31,11 @@ impl Availability {31
#[derive(Debug, Clone, Copy, PartialEq, Eq)]31
#[derive(Debug, Clone, Copy, PartialEq, Eq)]32
pub struct Presence {32
pub struct Presence {33
pub availability: Availability,33
pub availability: Availability,34
pub in_call: bool,35
}36
37
fn is_call_activity(activity: Option<&str>) -> bool {38
matches!(activity, Some("InACall" | "InAConferenceCall"))34
}39
}35
40
36
impl<R: Remote> SyncEngine<R> {41
impl<R: Remote> SyncEngine<R> {@@ -56,6 +61,7 @@ impl<R: Remote> SyncEngine<R> {56
for entry in found {61
for entry in found {57
let presence = Presence {62
let presence = Presence {58
availability: Availability::from_service(&entry.availability),63
availability: Availability::from_service(&entry.availability),64
in_call: is_call_activity(entry.activity.as_deref()),59
};65
};60
changed |= known.insert(entry.user_id, presence) != Some(presence);66
changed |= known.insert(entry.user_id, presence) != Some(presence);61
}67
}