From 9a2950a31799e3119a98e6a67c84969bce2ae270 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 3 Dec 2021 10:44:33 +0000 Subject: [PATCH 1/2] Don't inhibit current room notifications if user has Modal open --- src/Notifier.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Notifier.ts b/src/Notifier.ts index c03655f2096..b7221f72b56 100644 --- a/src/Notifier.ts +++ b/src/Notifier.ts @@ -383,7 +383,10 @@ export const Notifier = { const room = MatrixClientPeg.get().getRoom(ev.getRoomId()); const actions = MatrixClientPeg.get().getPushActionsForEvent(ev); if (actions && actions.notify) { - if (RoomViewStore.getRoomId() === room.roomId && UserActivity.sharedInstance().userActiveRecently()) { + if (RoomViewStore.getRoomId() === room.roomId && + UserActivity.sharedInstance().userActiveRecently() && + !Modal.hasDialogs() + ) { // don't bother notifying as user was recently active in this room return; } From 164a6ff774bd3a904466b4f6931b1dd3175047cb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 3 Dec 2021 10:44:42 +0000 Subject: [PATCH 2/2] Improve platform types --- src/BasePlatform.ts | 10 ++++++---- src/Notifier.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 9aabe82be5c..a4f91fc71bf 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -19,6 +19,10 @@ limitations under the License. import { MatrixClient } from "matrix-js-sdk/src/client"; import { encodeUnpaddedBase64 } from "matrix-js-sdk/src/crypto/olmlib"; +import { logger } from "matrix-js-sdk/src/logger"; +import { MatrixEvent } from "matrix-js-sdk/src/models/event"; +import { Room } from "matrix-js-sdk/src/models/room"; + import dis from './dispatcher/dispatcher'; import BaseEventIndexManager from './indexing/BaseEventIndexManager'; import { ActionPayload } from "./dispatcher/payloads"; @@ -28,8 +32,6 @@ import { hideToast as hideUpdateToast } from "./toasts/UpdateToast"; import { MatrixClientPeg } from "./MatrixClientPeg"; import { idbLoad, idbSave, idbDelete } from "./utils/StorageManager"; -import { logger } from "matrix-js-sdk/src/logger"; - export const SSO_HOMESERVER_URL_KEY = "mx_sso_hs_url"; export const SSO_ID_SERVER_URL_KEY = "mx_sso_is_url"; export const SSO_IDP_ID_KEY = "mx_sso_idp_id"; @@ -168,9 +170,9 @@ export default abstract class BasePlatform { */ abstract requestNotificationPermission(): Promise; - abstract displayNotification(title: string, msg: string, avatarUrl: string, room: Object); + abstract displayNotification(title: string, msg: string, avatarUrl: string, room: Room); - loudNotification(ev: Event, room: Object) { + loudNotification(ev: MatrixEvent, room: Room) { } clearNotification(notif: Notification) { diff --git a/src/Notifier.ts b/src/Notifier.ts index b7221f72b56..3f5c7fe0a68 100644 --- a/src/Notifier.ts +++ b/src/Notifier.ts @@ -379,7 +379,7 @@ export const Notifier = { } }, - _evaluateEvent: function(ev) { + _evaluateEvent: function(ev: MatrixEvent) { const room = MatrixClientPeg.get().getRoom(ev.getRoomId()); const actions = MatrixClientPeg.get().getPushActionsForEvent(ev); if (actions && actions.notify) {