[MM-60984] Force reload of all channels on reconnect to ensure we have updated message counts (#29355)

* [MM-60984] Force reload of all channels on reconnect to ensure we have updated message counts

* PR feedback

* Fix test
Этот коммит содержится в:
Devin Binnie
2024-11-27 08:14:11 -05:00
коммит произвёл GitHub
родитель 54eff271bd
Коммит 99f242527e
2 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@@ -33,6 +33,7 @@ import {
markMultipleChannelsAsRead,
getChannelMemberCountsByGroup,
fetchAllMyChannelMembers,
fetchAllMyTeamsChannels,
} from 'mattermost-redux/actions/channels';
import {getCloudSubscription} from 'mattermost-redux/actions/cloud';
import {clearErrors, logError} from 'mattermost-redux/actions/errors';
@@ -106,7 +107,7 @@ import {sendDesktopNotification} from 'actions/notification_actions';
import {handleNewPost} from 'actions/post_actions';
import * as StatusActions from 'actions/status_actions';
import {setGlobalItem} from 'actions/storage';
import {loadProfilesForDM, loadProfilesForGM} from 'actions/user_actions';
import {loadProfilesForDM, loadProfilesForGM, loadProfilesForSidebar} from 'actions/user_actions';
import {syncPostsInChannel} from 'actions/views/channel';
import {setGlobalDraft, transformServerDraft} from 'actions/views/drafts';
import {openModal} from 'actions/views/modals';
@@ -237,9 +238,10 @@ export function reconnect() {
dispatch(handleRefreshAppsBindings());
}
dispatch(loadChannelsForCurrentUser());
dispatch(fetchAllMyTeamsChannels());
dispatch(fetchAllMyChannelMembers());
dispatch(fetchMyCategories(currentTeamId));
dispatch(loadProfilesForSidebar());
if (mostRecentPost) {
dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at));

Просмотреть файл

@@ -3,6 +3,7 @@
import {CloudTypes} from 'mattermost-redux/action_types';
import {fetchMyCategories} from 'mattermost-redux/actions/channel_categories';
import {fetchAllMyTeamsChannels} from 'mattermost-redux/actions/channels';
import {getGroup} from 'mattermost-redux/actions/groups';
import {
getPostThreads,
@@ -72,6 +73,7 @@ jest.mock('mattermost-redux/actions/users', () => ({
jest.mock('mattermost-redux/actions/channels', () => ({
getChannelStats: jest.fn(() => ({type: 'GET_CHANNEL_STATS'})),
fetchAllMyChannelMembers: jest.fn(() => ({type: 'FETCH_ALL_MY_CHANNEL_MEMBERS'})),
fetchAllMyTeamsChannels: jest.fn(),
}));
jest.mock('actions/post_actions', () => ({
@@ -79,6 +81,11 @@ jest.mock('actions/post_actions', () => ({
handleNewPost: jest.fn(() => ({type: 'HANDLE_NEW_POST'})),
}));
jest.mock('actions/user_actions', () => ({
...jest.requireActual('actions/user_actions'),
loadProfilesForSidebar: jest.fn(),
}));
jest.mock('actions/global_actions', () => ({
...jest.requireActual('actions/global_actions'),
redirectUserToDefaultTeam: jest.fn(),
@@ -652,6 +659,11 @@ describe('reconnect', () => {
reconnect();
expect(fetchMyCategories).toHaveBeenCalledWith('currentTeamId');
});
test('should call fetchAllMyTeamsChannels when socket reconnects', () => {
reconnect();
expect(fetchAllMyTeamsChannels).toHaveBeenCalled();
});
});
describe('handleChannelUpdatedEvent', () => {