Device manager - silence call ringers when local notifications are silenced (#9420)

* silence call ringers when local notifications are silenced

* more coverage for silencing

* explain disabled silence button

* lint

* increase wait for modal

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Kerry 2022-10-17 11:16:04 +02:00 committed by GitHub
parent 1d1860842e
commit 2d9f828810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 280 additions and 8 deletions

View file

@ -62,6 +62,7 @@ import { KIND_CALL_TRANSFER } from "./components/views/dialogs/InviteDialogTypes
import { OpenInviteDialogPayload } from "./dispatcher/payloads/OpenInviteDialogPayload";
import { findDMForUser } from './utils/dm/findDMForUser';
import { getJoinedNonFunctionalMembers } from './utils/room/getJoinedNonFunctionalMembers';
import { localNotificationsAreSilenced } from './utils/notifications';
export const PROTOCOL_PSTN = 'm.protocol.pstn';
export const PROTOCOL_PSTN_PREFIXED = 'im.vector.protocol.pstn';
@ -184,6 +185,11 @@ export default class LegacyCallHandler extends EventEmitter {
}
}
public isForcedSilent(): boolean {
const cli = MatrixClientPeg.get();
return localNotificationsAreSilenced(cli);
}
public silenceCall(callId: string): void {
this.silencedCalls.add(callId);
this.emit(LegacyCallHandlerEvent.SilencedCallsChanged, this.silencedCalls);
@ -194,13 +200,14 @@ export default class LegacyCallHandler extends EventEmitter {
}
public unSilenceCall(callId: string): void {
if (this.isForcedSilent) return;
this.silencedCalls.delete(callId);
this.emit(LegacyCallHandlerEvent.SilencedCallsChanged, this.silencedCalls);
this.play(AudioID.Ring);
}
public isCallSilenced(callId: string): boolean {
return this.silencedCalls.has(callId);
return this.isForcedSilent() || this.silencedCalls.has(callId);
}
/**
@ -582,7 +589,7 @@ export default class LegacyCallHandler extends EventEmitter {
action.value === "ring"
));
if (pushRuleEnabled && tweakSetToRing) {
if (pushRuleEnabled && tweakSetToRing && !this.isForcedSilent()) {
this.play(AudioID.Ring);
} else {
this.silenceCall(call.callId);

View file

@ -806,13 +806,14 @@
"Video call started": "Video call started",
"Video": "Video",
"Close": "Close",
"Sound on": "Sound on",
"Silence call": "Silence call",
"Notifications silenced": "Notifications silenced",
"Unknown caller": "Unknown caller",
"Voice call": "Voice call",
"Video call": "Video call",
"Decline": "Decline",
"Accept": "Accept",
"Sound on": "Sound on",
"Silence call": "Silence call",
"Use app for a better experience": "Use app for a better experience",
"%(brand)s is experimental on a mobile web browser. For a better experience and the latest features, use our free native app.": "%(brand)s is experimental on a mobile web browser. For a better experience and the latest features, use our free native app.",
"Use app": "Use app",

View file

@ -85,6 +85,12 @@ export default class IncomingLegacyCallToast extends React.Component<IProps, ISt
const call = this.props.call;
const room = MatrixClientPeg.get().getRoom(LegacyCallHandler.instance.roomIdForCall(call));
const isVoice = call.type === CallType.Voice;
const callForcedSilent = LegacyCallHandler.instance.isForcedSilent();
let silenceButtonTooltip = this.state.silenced ? _t("Sound on") : _t("Silence call");
if (callForcedSilent) {
silenceButtonTooltip = _t("Notifications silenced");
}
const contentClass = classNames("mx_IncomingLegacyCallToast_content", {
"mx_IncomingLegacyCallToast_content_voice": isVoice,
@ -128,8 +134,9 @@ export default class IncomingLegacyCallToast extends React.Component<IProps, ISt
</div>
<AccessibleTooltipButton
className={silenceClass}
disabled={callForcedSilent}
onClick={this.onSilenceClick}
title={this.state.silenced ? _t("Sound on") : _t("Silence call")}
title={silenceButtonTooltip}
/>
</React.Fragment>;
}