From bab2620b59c2f210d3078bcfddb20f999956b720 Mon Sep 17 00:00:00 2001 From: M-ZubairAhmed Date: Wed, 19 Apr 2023 16:21:10 +0530 Subject: [PATCH] MM-50123 : Identify causes of removal of channel and channel members re fetching on team switch (#22984) --- .../channels/src/actions/channel_actions.ts | 21 ++++++++----------- .../team_controller/actions/index.ts | 17 +-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/webapp/channels/src/actions/channel_actions.ts b/webapp/channels/src/actions/channel_actions.ts index b3c9ffb156..c800d0fda1 100644 --- a/webapp/channels/src/actions/channel_actions.ts +++ b/webapp/channels/src/actions/channel_actions.ts @@ -254,25 +254,22 @@ export function fetchChannelsAndMembers(teamId: Team['id'] = ''): ActionFunc<{ch teamId, data: channels, }); - actions.push({ - type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS, - data: channelMembers, - }); - actions.push({ - type: RoleTypes.RECEIVED_ROLES, - data: roles, - }); } else { actions.push({ type: ChannelTypes.RECEIVED_ALL_CHANNELS, data: channels, }); - actions.push({ - type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS, - data: channelMembers, - }); } + actions.push({ + type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS, + data: channelMembers, + }); + actions.push({ + type: RoleTypes.RECEIVED_ROLES, + data: roles, + }); + await dispatch(batchActions(actions)); return {data: {channels, channelMembers, roles}}; diff --git a/webapp/channels/src/components/team_controller/actions/index.ts b/webapp/channels/src/components/team_controller/actions/index.ts index 38977f2678..e1717d0dbc 100644 --- a/webapp/channels/src/components/team_controller/actions/index.ts +++ b/webapp/channels/src/components/team_controller/actions/index.ts @@ -4,10 +4,9 @@ import {ActionFunc} from 'mattermost-redux/types/actions'; import {getTeamByName, selectTeam} from 'mattermost-redux/actions/teams'; import {forceLogoutIfNecessary} from 'mattermost-redux/actions/helpers'; -import {fetchMyChannelsAndMembersREST} from 'mattermost-redux/actions/channels'; import {getGroups, getAllGroupsAssociatedToChannelsInTeam, getAllGroupsAssociatedToTeam, getGroupsByUserIdPaginated} from 'mattermost-redux/actions/groups'; import {logError} from 'mattermost-redux/actions/errors'; -import {isCustomGroupsEnabled, isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences'; +import {isCustomGroupsEnabled} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentUser} from 'mattermost-redux/selectors/entities/users'; import {getLicense} from 'mattermost-redux/selectors/entities/general'; @@ -15,7 +14,6 @@ import {isSuccess} from 'types/actions'; import {loadStatusesForChannelAndSidebar} from 'actions/status_actions'; import {addUserToTeam} from 'actions/team_actions'; -import {fetchChannelsAndMembers} from 'actions/channel_actions'; import LocalStorageStore from 'stores/local_storage_store'; @@ -30,19 +28,6 @@ export function initializeTeam(team: Team): ActionFunc { const currentUser = getCurrentUser(state); LocalStorageStore.setPreviousTeamId(currentUser.id, team.id); - const graphQLEnabled = isGraphQLEnabled(state); - try { - if (graphQLEnabled) { - await dispatch(fetchChannelsAndMembers(team.id)); - } else { - await dispatch(fetchMyChannelsAndMembersREST(team.id)); - } - } catch (error) { - forceLogoutIfNecessary(error as ServerError, dispatch, getState); - dispatch(logError(error as ServerError)); - return {error: error as ServerError}; - } - dispatch(loadStatusesForChannelAndSidebar()); const license = getLicense(state);