From db139627ff548101d35cbc3b20a23faac8a6e7be Mon Sep 17 00:00:00 2001 From: Claudio Costa Date: Thu, 14 Sep 2023 15:23:18 -0600 Subject: [PATCH] [MM-54494] Update selector to get profiles connected to calls (#24544) * Update selector to get profiles connected to calls * Clean plugin version --- .../channels/src/components/profile_popover/index.ts | 10 +++++----- .../mattermost-redux/src/selectors/entities/common.ts | 4 ++-- webapp/channels/src/selectors/calls.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp/channels/src/components/profile_popover/index.ts b/webapp/channels/src/components/profile_popover/index.ts index 146817fd67..92c6a92dbe 100644 --- a/webapp/channels/src/components/profile_popover/index.ts +++ b/webapp/channels/src/components/profile_popover/index.ts @@ -13,7 +13,7 @@ import { getChannelByName, getChannelMember, } from 'mattermost-redux/selectors/entities/channels'; -import {getCallsConfig, getCalls} from 'mattermost-redux/selectors/entities/common'; +import {getCallsConfig, getProfilesInCalls} from 'mattermost-redux/selectors/entities/common'; import {getTeammateNameDisplaySetting} from 'mattermost-redux/selectors/entities/preferences'; import { getCurrentTeam, @@ -53,11 +53,11 @@ function getDefaultChannelId(state: GlobalState) { export function checkUserInCall(state: GlobalState, userId: string) { let isUserInCall = false; - const calls = getCalls(state); - Object.keys(calls).forEach((channelId) => { - const usersInCall = calls[channelId] || []; + const profilesInCalls = getProfilesInCalls(state); + Object.keys(profilesInCalls).forEach((channelId) => { + const profiles = profilesInCalls[channelId] || []; - for (const user of usersInCall) { + for (const user of profiles) { if (user.id === userId) { isUserInCall = true; break; diff --git a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/common.ts b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/common.ts index 297d19f09b..cf2568fa4d 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/common.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/common.ts @@ -71,10 +71,10 @@ export function getUsers(state: GlobalState): IDMappedObjects { // Calls -export function getCalls(state: GlobalState): Record { +export function getProfilesInCalls(state: GlobalState): Record { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - return state[CALLS_PLUGIN].voiceConnectedProfiles || {}; + return state[CALLS_PLUGIN].profiles || state[CALLS_PLUGIN].voiceConnectedProfiles || {}; } export function getCallsConfig(state: GlobalState): CallsConfig { diff --git a/webapp/channels/src/selectors/calls.ts b/webapp/channels/src/selectors/calls.ts index 64f5dc0438..f64e8a8cc8 100644 --- a/webapp/channels/src/selectors/calls.ts +++ b/webapp/channels/src/selectors/calls.ts @@ -9,7 +9,7 @@ import type {GlobalState} from 'types/store'; export function isCallsEnabled(state: GlobalState, minVersion = '0.4.2') { return Boolean(state.plugins.plugins[suitePluginIds.calls] && - semver.gte(state.plugins.plugins[suitePluginIds.calls].version || '0.0.0', minVersion)); + semver.gte(String(semver.clean(state.plugins.plugins[suitePluginIds.calls].version || '0.0.0')), minVersion)); } // isCallsRingingEnabledOnServer is the flag for the ringing/notification feature in calls