瀏覽代碼

fix(features/notifications): crash on undefined participant

master
paweldomas 5 年之前
父節點
當前提交
14855f3255
共有 1 個檔案被更改,包括 3 行新增2 行删除
  1. 3
    2
      react/features/notifications/middleware.js

+ 3
- 2
react/features/notifications/middleware.js 查看文件

@@ -84,9 +84,10 @@ MiddlewareRegistry.register(store => next => action => {
84 84
 
85 85
         const { id, role } = action.participant;
86 86
         const state = store.getState();
87
-        const { role: oldRole } = getParticipantById(state, id);
87
+        const oldParticipant = getParticipantById(state, id);
88
+        const oldRole = oldParticipant?.role;
88 89
 
89
-        if (oldRole !== role && role === PARTICIPANT_ROLE.MODERATOR) {
90
+        if (oldRole && oldRole !== role && role === PARTICIPANT_ROLE.MODERATOR) {
90 91
             const displayName = getParticipantDisplayName(state, id);
91 92
 
92 93
             store.dispatch(showNotification({

Loading…
取消
儲存