Inhibit local notifications when local notifications are silenced (#9328)

This commit is contained in:
Germain 2022-09-29 15:23:02 +01:00 committed by GitHub
parent 951cad98d3
commit a49603b9b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 122 additions and 5 deletions

View file

@ -46,6 +46,7 @@ import { mediaFromMxc } from "./customisations/Media";
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
import LegacyCallHandler from "./LegacyCallHandler";
import VoipUserMapper from "./VoipUserMapper";
import { localNotificationsAreSilenced } from "./utils/notifications";
/*
* Dispatches:
@ -90,8 +91,9 @@ export const Notifier = {
return TextForEvent.textForEvent(ev);
},
_displayPopupNotification: function(ev: MatrixEvent, room: Room) {
_displayPopupNotification: function(ev: MatrixEvent, room: Room): void {
const plaf = PlatformPeg.get();
const cli = MatrixClientPeg.get();
if (!plaf) {
return;
}
@ -99,6 +101,10 @@ export const Notifier = {
return;
}
if (localNotificationsAreSilenced(cli)) {
return;
}
let msg = this.notificationMessageForEvent(ev);
if (!msg) return;
@ -170,7 +176,12 @@ export const Notifier = {
};
},
_playAudioNotification: async function(ev: MatrixEvent, room: Room) {
_playAudioNotification: async function(ev: MatrixEvent, room: Room): Promise<void> {
const cli = MatrixClientPeg.get();
if (localNotificationsAreSilenced(cli)) {
return;
}
const sound = this.getSoundForRoom(room.roomId);
logger.log(`Got sound ${sound && sound.name || "default"} for ${room.roomId}`);
@ -325,7 +336,7 @@ export const Notifier = {
}
const isGuest = client.isGuest();
return !isGuest && this.supportsDesktopNotifications() && !isPushNotifyDisabled() &&
!this.isEnabled() && !this._isPromptHidden();
!localNotificationsAreSilenced(client) && !this.isEnabled() && !this._isPromptHidden();
},
_isPromptHidden: function() {