From 14855f3255b91960079da5a4ff38a8ceb3441222 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Thu, 19 Mar 2020 12:40:36 -0500 Subject: [PATCH] fix(features/notifications): crash on undefined participant --- react/features/notifications/middleware.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/react/features/notifications/middleware.js b/react/features/notifications/middleware.js index 02f3b876c..d30e1e1a8 100644 --- a/react/features/notifications/middleware.js +++ b/react/features/notifications/middleware.js @@ -84,9 +84,10 @@ MiddlewareRegistry.register(store => next => action => { const { id, role } = action.participant; const state = store.getState(); - const { role: oldRole } = getParticipantById(state, id); + const oldParticipant = getParticipantById(state, id); + const oldRole = oldParticipant?.role; - if (oldRole !== role && role === PARTICIPANT_ROLE.MODERATOR) { + if (oldRole && oldRole !== role && role === PARTICIPANT_ROLE.MODERATOR) { const displayName = getParticipantDisplayName(state, id); store.dispatch(showNotification({