From e8a80bd72972aaa62f8a8c9eee39238ea7cff81f Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:33:48 -0400 Subject: [PATCH] [MM-61361] Force reconnect handler to fetch channel categories on reconnect (#29010) Co-authored-by: Mattermost Build --- webapp/channels/src/actions/websocket_actions.jsx | 1 + .../channels/src/actions/websocket_actions.test.jsx | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/webapp/channels/src/actions/websocket_actions.jsx b/webapp/channels/src/actions/websocket_actions.jsx index 566ff74a47..3ef7532ea7 100644 --- a/webapp/channels/src/actions/websocket_actions.jsx +++ b/webapp/channels/src/actions/websocket_actions.jsx @@ -237,6 +237,7 @@ export function reconnect() { dispatch(loadChannelsForCurrentUser()); dispatch(fetchAllMyChannelMembers()); + dispatch(fetchMyCategories(currentTeamId)); if (mostRecentPost) { dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at)); diff --git a/webapp/channels/src/actions/websocket_actions.test.jsx b/webapp/channels/src/actions/websocket_actions.test.jsx index 78ca412a07..8f1bd5b0ee 100644 --- a/webapp/channels/src/actions/websocket_actions.test.jsx +++ b/webapp/channels/src/actions/websocket_actions.test.jsx @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import {UserTypes, CloudTypes} from 'mattermost-redux/action_types'; +import {fetchMyCategories} from 'mattermost-redux/actions/channel_categories'; import {getGroup} from 'mattermost-redux/actions/groups'; import { getPostThreads, @@ -44,6 +45,11 @@ jest.mock('mattermost-redux/actions/posts', () => ({ getMentionsAndStatusesForPosts: jest.fn(), })); +jest.mock('mattermost-redux/actions/channel_categories', () => ({ + ...jest.requireActual('mattermost-redux/actions/channel_categories'), + fetchMyCategories: jest.fn(), +})); + jest.mock('mattermost-redux/actions/status_profile_polling', () => ({ ...jest.requireActual('mattermost-redux/actions/status_profile_polling'), batchFetchStatusesProfilesGroupsFromPosts: jest.fn(() => ({type: ''})), @@ -637,6 +643,11 @@ describe('reconnect', () => { reconnect(); expect(syncPostsInChannel).toHaveBeenCalledWith('otherChannel', '12345'); }); + + test('should call fetchMyCategories when socket reconnects', () => { + reconnect(); + expect(fetchMyCategories).toHaveBeenCalledWith('currentTeamId'); + }); }); describe('handleChannelUpdatedEvent', () => {