Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/actions/remote/entry/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {RESULTS} from 'react-native-permissions';

import {handleKickFromChannel, fetchMyChannelsForTeam} from '@actions/remote/channel';
import {fetchMyPreferences} from '@actions/remote/preference';
import {fetchRoles} from '@actions/remote/role';
import {fetchConfigAndLicense} from '@actions/remote/systems';
import {fetchMyTeams, handleKickFromTeam} from '@actions/remote/team';
import {fetchMe} from '@actions/remote/user';
Expand All @@ -25,6 +26,7 @@ import {entry, setExtraSessionProps, verifyPushProxy, entryInitialChannelId, han
jest.mock('@actions/remote/channel');
jest.mock('@actions/remote/scheduled_post');
jest.mock('@actions/remote/preference');
jest.mock('@actions/remote/role');
jest.mock('@actions/remote/systems');
jest.mock('@actions/remote/team');
jest.mock('@actions/remote/user');
Expand Down Expand Up @@ -129,6 +131,7 @@ describe('actions/remote/entry/common', () => {
meData: mockUser,
isCRTEnabled: false,
});
expect(fetchRoles).toHaveBeenCalled();

expect(result).toEqual(expect.objectContaining({
initialChannelId: '',
Expand Down
11 changes: 8 additions & 3 deletions app/actions/remote/entry/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {RESULTS, checkNotifications} from 'react-native-permissions';
import {deletePostsForChannel, deletePostsForChannelsWithAutotranslation} from '@actions/local/channel';
import {fetchChannelById, fetchMyChannelsForTeam, handleKickFromChannel, type MyChannelsRequest} from '@actions/remote/channel';
import {type MyPreferencesRequest, fetchMyPreferences} from '@actions/remote/preference';
import {fetchRoles} from '@actions/remote/role';
import {fetchConfigAndLicense, fetchDataRetentionPolicy} from '@actions/remote/systems';
import {fetchMyTeams, handleKickFromTeam, type MyTeamsRequest} from '@actions/remote/team';
import {fetchMe, type MyUserRequest} from '@actions/remote/user';
Expand Down Expand Up @@ -183,10 +184,14 @@ const entryRest = async (serverUrl: string, teamId?: string, channelId?: string,

await handleAutotranslationChanges(serverUrl, meData, chData);

const modelPromises = await prepareEntryModels({operator, teamData: initialTeamData, chData, prefData, meData, isCRTEnabled});
const models = (await Promise.all(modelPromises)).flat();
logDebug('Process models on entry', groupLabel, models.length, `${Date.now() - dt}ms`);
const [models] = await Promise.all([
prepareEntryModels({operator, teamData: initialTeamData, chData, prefData, meData, isCRTEnabled}).
then((proms) => Promise.all(proms)).
then((results) => results.flat()),
fetchRoles(serverUrl, teamData.memberships, chData?.memberships, meData?.user, false, false, groupLabel),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say is fine if you want to add them here, it does not really mean it will be more realiable, but in any case if you do this probably you want to remove the other fetch call that happens down the line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, without this I can reproduce the issue in bad network conditions

]);

logDebug('Process models on entry', groupLabel, models.length, `${Date.now() - dt}ms`);
return {models, initialChannelId, initialTeamId, prefData, teamData, chData, meData, gmConverted};
} catch (error) {
logError('entryRest', groupLabel, error);
Expand Down
Loading