Skip to content

Commit

Permalink
Merge branch 'rm/321019' into 'master'
Browse files Browse the repository at this point in the history
Fix: group channels members not loaded when category is collapsed

See merge request kchat/webapp!693
  • Loading branch information
antonbuks committed Apr 12, 2024
2 parents 1857896 + 9e934c2 commit fd5e9aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
10 changes: 2 additions & 8 deletions webapp/channels/src/actions/user_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {calculateUnreadCount} from 'mattermost-redux/utils/channel_utils';

import {loadCustomEmojisForCustomStatusesByUserIds} from 'actions/emoji_actions';
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions';
import {getDisplayedChannels} from 'selectors/views/channel_sidebar';
import {getDisplayedChannels, getSidebarGroupChannels} from 'selectors/views/channel_sidebar';
import store from 'stores/redux_store';

import {Constants, Preferences, UserStatuses} from 'utils/constants';
Expand Down Expand Up @@ -303,13 +303,7 @@ export async function loadProfilesForSidebar() {
}

export const getGMsForLoading = (state: GlobalState) => {
// Get all channels visible on the current team which doesn't include hidden GMs/DMs
let channels = getDisplayedChannels(state);

// Make sure we only have GMs
channels = channels.filter((channel) => channel.type === General.GM_CHANNEL);

return channels;
return getSidebarGroupChannels(state);
};

export async function loadProfilesForGM() {
Expand Down
20 changes: 20 additions & 0 deletions webapp/channels/src/selectors/views/channel_sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from 'mattermost-redux/selectors/entities/channels';
import {shouldShowUnreadsCategory, isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {isGroupChannel} from 'mattermost-redux/utils/channel_utils';
import {memoizeResult} from 'mattermost-redux/utils/helpers';

import type {DraggingState, GlobalState} from 'types/store';
Expand Down Expand Up @@ -103,6 +104,17 @@ export const getChannelsInCategoryOrder = (() => {
);
})();

export const getAllChannelsInCategoryOrder = (() => {
return createSelector(
'getAllChannelsInCategoryOrder',
getCategoriesForCurrentTeam,
getChannelsByCategoryForCurrentTeam,
(categories, channelsByCategory) => {
return categories.map((category) => channelsByCategory[category.id]).flat();
},
);
})();

// getUnreadChannels returns an array of all unread channels on the current team for display with the unread filter
// enabled. Channels are sorted by recency with channels containing a mention grouped first.
export const getUnreadChannels = (() => {
Expand Down Expand Up @@ -188,6 +200,14 @@ export const getDisplayedChannels = createSelector(
},
);

export const getSidebarGroupChannels = createSelector(
'getSidebarGroupChannels',
getAllChannelsInCategoryOrder,
(allChannels) => {
return allChannels.filter(isGroupChannel);
},
);

// Returns a selector that, given a category, returns the ids of channels visible in that category. The returned channels do not
// include unread channels when the Unreads category is enabled.
export function makeGetFilteredChannelIdsForCategory(): (state: GlobalState, category: ChannelCategory) => string[] {
Expand Down

0 comments on commit fd5e9aa

Please sign in to comment.