Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Don't inhibit current room notifications if user has Modal open #7274

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -168,9 +170,9 @@ export default abstract class BasePlatform {
*/
abstract requestNotificationPermission(): Promise<string>;

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) {
Expand Down
7 changes: 5 additions & 2 deletions src/Notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,14 @@ 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) {
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;
}
Expand Down