diff --git a/webapp/channels/src/actions/channel_actions.ts b/webapp/channels/src/actions/channel_actions.ts index c800d0fda1..b3c9ffb156 100644 --- a/webapp/channels/src/actions/channel_actions.ts +++ b/webapp/channels/src/actions/channel_actions.ts @@ -254,22 +254,25 @@ 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 e1717d0dbc..38977f2678 100644 --- a/webapp/channels/src/components/team_controller/actions/index.ts +++ b/webapp/channels/src/components/team_controller/actions/index.ts @@ -4,9 +4,10 @@ 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} from 'mattermost-redux/selectors/entities/preferences'; +import {isCustomGroupsEnabled, isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentUser} from 'mattermost-redux/selectors/entities/users'; import {getLicense} from 'mattermost-redux/selectors/entities/general'; @@ -14,6 +15,7 @@ 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'; @@ -28,6 +30,19 @@ 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);