diff --git a/src/core/resource/audioVideo/modules/AudioVideo.module.js b/src/core/resource/audioVideo/modules/AudioVideo.module.js index a55a6cad487b9717c29a79771e69dbf390321e8e..d9a1d09b47df514b76d0c70d59d739752305f8b2 100644 --- a/src/core/resource/audioVideo/modules/AudioVideo.module.js +++ b/src/core/resource/audioVideo/modules/AudioVideo.module.js @@ -58,6 +58,7 @@ const updateRoomCallInfo = createAction('AUDIO_VIDEO_UPDATE_ROOM_INFO'); const checkRoomCallInfo = createAction('AUDIO_VIDEO_CHECK_ROOM_INFO'); // payload: true / false const requestMinimize = createAction('AUDIO_VIDEO_REQUEST_MINIMIZE'); +const updateAdminStatusCurrentUser = createAction('AUDIO_VIDEO_UPDATE_ADMIN_STATUS_CURRENT_USER'); const initHandlerBase = (state, payload) => Object.assign( {}, @@ -183,10 +184,13 @@ const handleRequestMinimise = (state, payload) => { if (!state.conferenceId) { return state; } - return { ...state, minimizeRequested: !!payload }; + return { ...state, minimizeRequested: !!payload }; }; +const updateAdminStatusCurrentUserHandler = (state, payload) => { + return { ...state, isAdmin: payload.isAdmin }; +}; const audioVideo = createReducer((on) => { on(incomingCall, initIncomingCall); @@ -205,6 +209,7 @@ const audioVideo = createReducer((on) => { on(startP2pCallInit, initHandlerBase); on(updateRoomCallInfo, initUpdateRoomInfo); on(requestMinimize, handleRequestMinimise); + on(updateAdminStatusCurrentUser, updateAdminStatusCurrentUserHandler); }, initialState); const getCallData = (state, conferenceId) => { @@ -357,6 +362,7 @@ const audioVideoActions = { updateRoomCallInfo, checkRoomCallInfo, requestMinimize, + updateAdminStatusCurrentUser, }; const audioVideoSelectors = { diff --git a/src/core/resource/audioVideo/sagas/AudioVideo.saga.js b/src/core/resource/audioVideo/sagas/AudioVideo.saga.js index 85c7d7d1c0af979c5137935412f40c18bad76376..ddd14bf929f03041e16899197bf1b3511a3c6ea0 100644 --- a/src/core/resource/audioVideo/sagas/AudioVideo.saga.js +++ b/src/core/resource/audioVideo/sagas/AudioVideo.saga.js @@ -120,6 +120,10 @@ function* callUpdate(action) { try { const phoneId = yield select(profileSelectors.getPhoneId); isAdmin = payload.ownerAccountId === phoneId; + if (!isAdmin && (payload.chatRoomId || (callData && callData.chatRoomId))) { + const roomId = payload.chatRoomId || callData.chatRoomId; + isAdmin = yield select(roomListSelectors.isAdminInGroup, roomId, phoneId); + } } catch (e) { } if (payload.replaceCallId) { const clientId = payload.deviceId || callData.clientId || null; diff --git a/src/core/resource/roomlist/modules/RoomList.module.js b/src/core/resource/roomlist/modules/RoomList.module.js index a9204f2d12d8759912e77d26192551a5b1591baa..a284c5b4e754d29034625bc89241bb157496bd39 100644 --- a/src/core/resource/roomlist/modules/RoomList.module.js +++ b/src/core/resource/roomlist/modules/RoomList.module.js @@ -254,7 +254,18 @@ const getUnreadCountInGroup = (state, groupId) => { } return 0; -} +}; + +const isAdminInGroup = (state, groupId, phoneId) => { + const group = getRoomById(state, groupId); + if (group && group.admins) { + const adminMember = group.admins[phoneId]; + if (adminMember) { + return true; + } + } + return false; +}; const pullReceivedRoomList = ({ rosters = [] }) => { const data = {}; @@ -816,6 +827,7 @@ const roomListSelectors = { getTotalUnreadMentionsCount, getTotalUnreadCount, getGroupsByRosterIdRaw, + isAdminInGroup, }; export default roomList; diff --git a/src/core/resource/roomlist/sagas/Rooms.saga.js b/src/core/resource/roomlist/sagas/Rooms.saga.js index 99c0b89bccf93d6aa81765e49aa10f76bb532965..377ab2edbf90bd346fd912653cc17480c3d3c28d 100644 --- a/src/core/resource/roomlist/sagas/Rooms.saga.js +++ b/src/core/resource/roomlist/sagas/Rooms.saga.js @@ -653,18 +653,22 @@ function* responseIncommingRoomMember() { const addMembersJobKey = `room-add-members-${groupId}`; const updateStatusJobKey = `room-update-member-status-${groupId}`; const isInCall = yield select(audioVideoSelectors.hasActiveCall); + const callData = yield select(audioVideoSelectors.getCallData); let isSoundsEnabled = allAppSound && notifications && show; if (isInCall) { isSoundsEnabled = isSoundsEnabled && !muteUnmuteDuringCallNotifications; } + const shouldShowNotifications = allGroupEventsNotifications && notifications && show; + const isCallInGroup = callData && callData.chatRoomId === groupId; + /** * The response status from the server for adding new members/promoting members to admins/demoting admins to members * is the same for all three actions so some magic have to be done in order to deduce for which action is the response * MAGIC START */ - if (allGroupEventsNotifications && notifications && show) { + if (shouldShowNotifications || isCallInGroup) { const isAddMembersJob = yield call(getQueueJob, addMembersJobKey); const isUpdateStatusJob = yield call(getQueueJob, updateStatusJobKey); const type = notificationTypes.GROUP_EVENT_MESSAGE; @@ -690,10 +694,16 @@ function* responseIncommingRoomMember() { } if (isMyPromotion) { - const body = i18n - .t('groupsSystemMessages.adminPromotedYou') - .replace('$1', groupName); - showNotification(body, type, redirectLink, null, null, callback); + if (shouldShowNotifications) { + const body = i18n + .t('groupsSystemMessages.adminPromotedYou') + .replace('$1', groupName); + showNotification(body, type, redirectLink, null, null, callback); + } + + if (isCallInGroup) { + yield put(audioVideoActions.updateAdminStatusCurrentUser({ isAdmin: true })); + } } } else { const groupBeforeUpdate = yield select(roomListSelectors.getRoomById, groupId); @@ -740,13 +750,19 @@ function* responseIncommingRoomMember() { } if (isDemoting && isAboutMe) { - const body = i18n - .t('groupsSystemMessages.adminDemotedYou') - .replace('$1', groupName); - showNotification(body, type, redirectLink, null, null, callback); + if (shouldShowNotifications) { + const body = i18n + .t('groupsSystemMessages.adminDemotedYou') + .replace('$1', groupName); + showNotification(body, type, redirectLink, null, null, callback); + } + + if (isCallInGroup) { + yield put(audioVideoActions.updateAdminStatusCurrentUser({ isAdmin: false })); + } } - if (isAdding) { + if (isAdding && shouldShowNotifications) { let body = ''; if (isAboutMe) {