Fix crash on load and room creation (#418)
authorAjay Bura <32841439+ajbura@users.noreply.github.com>
Wed, 23 Mar 2022 13:14:53 +0000 (18:44 +0530)
committerGitHub <noreply@github.com>
Wed, 23 Mar 2022 13:14:53 +0000 (18:44 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/molecules/room-notification/RoomNotification.jsx
src/client/state/Notifications.js

index 26d123bc7a22f423fe89a8409559c407d2fe76be..0a3619f12ffaf57d583e56df8bee9d9fe984236f 100644 (file)
@@ -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) {
index 963385262b2469a4e6d89988e295d3146c68ff82..512b3e76259452a2e0680a8f9e3c358f4d6a3fbb 100644 (file)
@@ -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;