[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
54eff271bd
Коммит
99f242527e
@@ -33,6 +33,7 @@ import {
|
|||||||
markMultipleChannelsAsRead,
|
markMultipleChannelsAsRead,
|
||||||
getChannelMemberCountsByGroup,
|
getChannelMemberCountsByGroup,
|
||||||
fetchAllMyChannelMembers,
|
fetchAllMyChannelMembers,
|
||||||
|
fetchAllMyTeamsChannels,
|
||||||
} from 'mattermost-redux/actions/channels';
|
} from 'mattermost-redux/actions/channels';
|
||||||
import {getCloudSubscription} from 'mattermost-redux/actions/cloud';
|
import {getCloudSubscription} from 'mattermost-redux/actions/cloud';
|
||||||
import {clearErrors, logError} from 'mattermost-redux/actions/errors';
|
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 {handleNewPost} from 'actions/post_actions';
|
||||||
import * as StatusActions from 'actions/status_actions';
|
import * as StatusActions from 'actions/status_actions';
|
||||||
import {setGlobalItem} from 'actions/storage';
|
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 {syncPostsInChannel} from 'actions/views/channel';
|
||||||
import {setGlobalDraft, transformServerDraft} from 'actions/views/drafts';
|
import {setGlobalDraft, transformServerDraft} from 'actions/views/drafts';
|
||||||
import {openModal} from 'actions/views/modals';
|
import {openModal} from 'actions/views/modals';
|
||||||
@@ -237,9 +238,10 @@ export function reconnect() {
|
|||||||
dispatch(handleRefreshAppsBindings());
|
dispatch(handleRefreshAppsBindings());
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(loadChannelsForCurrentUser());
|
dispatch(fetchAllMyTeamsChannels());
|
||||||
dispatch(fetchAllMyChannelMembers());
|
dispatch(fetchAllMyChannelMembers());
|
||||||
dispatch(fetchMyCategories(currentTeamId));
|
dispatch(fetchMyCategories(currentTeamId));
|
||||||
|
dispatch(loadProfilesForSidebar());
|
||||||
|
|
||||||
if (mostRecentPost) {
|
if (mostRecentPost) {
|
||||||
dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at));
|
dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import {CloudTypes} from 'mattermost-redux/action_types';
|
import {CloudTypes} from 'mattermost-redux/action_types';
|
||||||
import {fetchMyCategories} from 'mattermost-redux/actions/channel_categories';
|
import {fetchMyCategories} from 'mattermost-redux/actions/channel_categories';
|
||||||
|
import {fetchAllMyTeamsChannels} from 'mattermost-redux/actions/channels';
|
||||||
import {getGroup} from 'mattermost-redux/actions/groups';
|
import {getGroup} from 'mattermost-redux/actions/groups';
|
||||||
import {
|
import {
|
||||||
getPostThreads,
|
getPostThreads,
|
||||||
@@ -72,6 +73,7 @@ jest.mock('mattermost-redux/actions/users', () => ({
|
|||||||
jest.mock('mattermost-redux/actions/channels', () => ({
|
jest.mock('mattermost-redux/actions/channels', () => ({
|
||||||
getChannelStats: jest.fn(() => ({type: 'GET_CHANNEL_STATS'})),
|
getChannelStats: jest.fn(() => ({type: 'GET_CHANNEL_STATS'})),
|
||||||
fetchAllMyChannelMembers: jest.fn(() => ({type: 'FETCH_ALL_MY_CHANNEL_MEMBERS'})),
|
fetchAllMyChannelMembers: jest.fn(() => ({type: 'FETCH_ALL_MY_CHANNEL_MEMBERS'})),
|
||||||
|
fetchAllMyTeamsChannels: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock('actions/post_actions', () => ({
|
jest.mock('actions/post_actions', () => ({
|
||||||
@@ -79,6 +81,11 @@ jest.mock('actions/post_actions', () => ({
|
|||||||
handleNewPost: jest.fn(() => ({type: 'HANDLE_NEW_POST'})),
|
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.mock('actions/global_actions', () => ({
|
||||||
...jest.requireActual('actions/global_actions'),
|
...jest.requireActual('actions/global_actions'),
|
||||||
redirectUserToDefaultTeam: jest.fn(),
|
redirectUserToDefaultTeam: jest.fn(),
|
||||||
@@ -652,6 +659,11 @@ describe('reconnect', () => {
|
|||||||
reconnect();
|
reconnect();
|
||||||
expect(fetchMyCategories).toHaveBeenCalledWith('currentTeamId');
|
expect(fetchMyCategories).toHaveBeenCalledWith('currentTeamId');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should call fetchAllMyTeamsChannels when socket reconnects', () => {
|
||||||
|
reconnect();
|
||||||
|
expect(fetchAllMyTeamsChannels).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handleChannelUpdatedEvent', () => {
|
describe('handleChannelUpdatedEvent', () => {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user