From 817d1792ce6b470bd92a2688755d1889fbf1d5ed Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Thu, 18 Jun 2020 03:21:03 +0200 Subject: [PATCH] Automated cherry pick of #4362 (#4438) * MM-24501 Load all (joinable) teams when resetting app state The subsequent `loadMe` only fetches a user's already-joined teams, which doesn't populate `state.entities.teams.teams` with the entire set of teams available, including potentially joinable teams. Fixes https://github.com/mattermost/mattermost-mobile/issues/4209 * Add names to batched team action groups Co-authored-by: Amit Uttam --- app/init/global_event_handler.js | 2 ++ app/mm-redux/actions/teams.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/init/global_event_handler.js b/app/init/global_event_handler.js index 87dbd9172..524cc21c2 100644 --- a/app/init/global_event_handler.js +++ b/app/init/global_event_handler.js @@ -18,6 +18,7 @@ import LocalConfig from '@assets/config'; import {NavigationTypes, ViewTypes} from '@constants'; import {getTranslations, resetMomentLocale} from '@i18n'; import {setAppState, setServerVersion} from '@mm-redux/actions/general'; +import {getTeams} from '@mm-redux/actions/teams'; import {autoUpdateTimezone} from '@mm-redux/actions/timezone'; import {close as closeWebSocket} from '@actions/websocket'; import {Client4} from '@mm-redux/client'; @@ -263,6 +264,7 @@ class GlobalEventHandler { const user = getUser(state, currentUserId); await dispatch(loadConfigAndLicense()); + await dispatch(getTeams()); await dispatch(loadMe(user)); const window = Dimensions.get('window'); diff --git a/app/mm-redux/actions/teams.ts b/app/mm-redux/actions/teams.ts index 14dfd9265..d51120108 100644 --- a/app/mm-redux/actions/teams.ts +++ b/app/mm-redux/actions/teams.ts @@ -132,7 +132,7 @@ export function getTeams(page = 0, perPage: number = General.TEAMS_CHUNK_SIZE, i }); } - dispatch(batchActions(actions)); + dispatch(batchActions(actions, 'BATCH_GET_TEAMS')); return {data}; }; @@ -164,7 +164,7 @@ export function searchTeams(term: string, page?: number, perPage?: number): Acti { type: TeamTypes.GET_TEAMS_SUCCESS, }, - ])); + ], 'BATCH_SEARCH_TEAMS')); return {data: response}; }; @@ -203,7 +203,7 @@ export function createTeam(team: Team): ActionFunc { type: TeamTypes.SELECT_TEAM, data: created.id, }, - ])); + ], 'BATCH_CREATE_TEAM')); dispatch(loadRolesIfNeeded(member.roles.split(' '))); return {data: created}; @@ -237,7 +237,7 @@ export function deleteTeam(teamId: string): ActionFunc { }, ); - dispatch(batchActions(actions)); + dispatch(batchActions(actions, 'BATCH_DELETE_TEAM')); return {data: true}; }; @@ -482,7 +482,7 @@ export function addUsersToTeam(teamId: string, userIds: Array): ActionFu type: TeamTypes.RECEIVED_MEMBERS_IN_TEAM, data: members, }, - ])); + ], 'BATCH_ADD_USERS_TO_TEAM')); return {data: members}; }; @@ -512,7 +512,7 @@ export function addUsersToTeamGracefully(teamId: string, userIds: Array) type: TeamTypes.RECEIVED_MEMBERS_IN_TEAM, data: members, }, - ])); + ], 'BATCH_ADD_USERS_TO_TEAM_GRACEFULLY')); return {data: result}; }; @@ -566,7 +566,7 @@ export function removeUserFromTeam(teamId: string, userId: string): ActionFunc { } } - dispatch(batchActions(actions)); + dispatch(batchActions(actions, 'BATCH_REMOVE_USER_FROM_TEAM')); return {data: true}; };