From e8d6ccec9a6d888cf5d9c7046c40e24d14286c34 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Wed, 23 Mar 2022 18:44:53 +0530 Subject: [PATCH] Fix crash on load and room creation (#418) Signed-off-by: Ajay Bura --- src/app/molecules/room-notification/RoomNotification.jsx | 7 ++++++- src/client/state/Notifications.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/molecules/room-notification/RoomNotification.jsx b/src/app/molecules/room-notification/RoomNotification.jsx index 26d123bc..0a3619f1 100644 --- a/src/app/molecules/room-notification/RoomNotification.jsx +++ b/src/app/molecules/room-notification/RoomNotification.jsx @@ -35,7 +35,12 @@ const items = [{ function setRoomNotifType(roomId, newType) { const mx = initMatrix.matrixClient; const { notifications } = initMatrix; - const roomPushRule = mx.getRoomPushRule('global', roomId); + let roomPushRule; + try { + roomPushRule = mx.getRoomPushRule('global', roomId); + } catch { + roomPushRule = undefined; + } const promises = []; if (newType === cons.notifs.MUTE) { diff --git a/src/client/state/Notifications.js b/src/client/state/Notifications.js index 96338526..512b3e76 100644 --- a/src/client/state/Notifications.js +++ b/src/client/state/Notifications.js @@ -83,7 +83,12 @@ class Notifications extends EventEmitter { getNotiType(roomId) { const mx = this.matrixClient; - const pushRule = mx.getRoomPushRule('global', roomId); + let pushRule; + try { + pushRule = mx.getRoomPushRule('global', roomId); + } catch { + pushRule = undefined; + } if (pushRule === undefined) { const overrideRules = mx.getAccountData('m.push_rules')?.getContent()?.global?.override;