[MM-54494] Update selector to get profiles connected to calls (#24544)

* Update selector to get profiles connected to calls

* Clean plugin version
This commit is contained in:
Claudio Costa 2023-09-14 15:23:18 -06:00 committed by GitHub
parent 0fb6e5169d
commit db139627ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -13,7 +13,7 @@ import {
getChannelByName, getChannelByName,
getChannelMember, getChannelMember,
} from 'mattermost-redux/selectors/entities/channels'; } 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 {getTeammateNameDisplaySetting} from 'mattermost-redux/selectors/entities/preferences';
import { import {
getCurrentTeam, getCurrentTeam,
@ -53,11 +53,11 @@ function getDefaultChannelId(state: GlobalState) {
export function checkUserInCall(state: GlobalState, userId: string) { export function checkUserInCall(state: GlobalState, userId: string) {
let isUserInCall = false; let isUserInCall = false;
const calls = getCalls(state); const profilesInCalls = getProfilesInCalls(state);
Object.keys(calls).forEach((channelId) => { Object.keys(profilesInCalls).forEach((channelId) => {
const usersInCall = calls[channelId] || []; const profiles = profilesInCalls[channelId] || [];
for (const user of usersInCall) { for (const user of profiles) {
if (user.id === userId) { if (user.id === userId) {
isUserInCall = true; isUserInCall = true;
break; break;

View File

@ -71,10 +71,10 @@ export function getUsers(state: GlobalState): IDMappedObjects<UserProfile> {
// Calls // Calls
export function getCalls(state: GlobalState): Record<string, UserProfile[]> { export function getProfilesInCalls(state: GlobalState): Record<string, UserProfile[]> {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
return state[CALLS_PLUGIN].voiceConnectedProfiles || {}; return state[CALLS_PLUGIN].profiles || state[CALLS_PLUGIN].voiceConnectedProfiles || {};
} }
export function getCallsConfig(state: GlobalState): CallsConfig { export function getCallsConfig(state: GlobalState): CallsConfig {

View File

@ -9,7 +9,7 @@ import type {GlobalState} from 'types/store';
export function isCallsEnabled(state: GlobalState, minVersion = '0.4.2') { export function isCallsEnabled(state: GlobalState, minVersion = '0.4.2') {
return Boolean(state.plugins.plugins[suitePluginIds.calls] && 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 // isCallsRingingEnabledOnServer is the flag for the ringing/notification feature in calls