MM-49603 : Remove fetching of deleted channels on page load (#22981)
- channel request types removed from fetchMyChannelsAndMembersREST - removed isMinimumServerVersion check from that above action call, which is adding the query to include the archived channels
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5e52b8a50e
Коммит
3f0ac142c4
@@ -4,6 +4,18 @@
|
|||||||
import {AnyAction} from 'redux';
|
import {AnyAction} from 'redux';
|
||||||
import {batchActions} from 'redux-batched-actions';
|
import {batchActions} from 'redux-batched-actions';
|
||||||
|
|
||||||
|
import {ServerError} from '@mattermost/types/errors';
|
||||||
|
import {
|
||||||
|
Channel,
|
||||||
|
ChannelNotifyProps,
|
||||||
|
ChannelMembership,
|
||||||
|
ChannelModerationPatch,
|
||||||
|
ChannelsWithTotalCount,
|
||||||
|
ChannelSearchOpts,
|
||||||
|
ServerChannel,
|
||||||
|
} from '@mattermost/types/channels';
|
||||||
|
import {PreferenceType} from '@mattermost/types/preferences';
|
||||||
|
|
||||||
import {ChannelTypes, PreferenceTypes, UserTypes} from 'mattermost-redux/action_types';
|
import {ChannelTypes, PreferenceTypes, UserTypes} from 'mattermost-redux/action_types';
|
||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
import {Client4} from 'mattermost-redux/client';
|
||||||
@@ -19,18 +31,12 @@ import {
|
|||||||
getRedirectChannelNameForTeam,
|
getRedirectChannelNameForTeam,
|
||||||
isManuallyUnread,
|
isManuallyUnread,
|
||||||
} from 'mattermost-redux/selectors/entities/channels';
|
} from 'mattermost-redux/selectors/entities/channels';
|
||||||
import {getConfig, getServerVersion} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||||
|
|
||||||
import {ActionFunc, ActionResult, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
|
import {ActionFunc, ActionResult, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
|
||||||
|
|
||||||
import {getChannelsIdForTeam, getChannelByName} from 'mattermost-redux/utils/channel_utils';
|
import {getChannelByName} from 'mattermost-redux/utils/channel_utils';
|
||||||
|
|
||||||
import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers';
|
|
||||||
|
|
||||||
import {Channel, ChannelNotifyProps, ChannelMembership, ChannelModerationPatch, ChannelsWithTotalCount, ChannelSearchOpts} from '@mattermost/types/channels';
|
|
||||||
|
|
||||||
import {PreferenceType} from '@mattermost/types/preferences';
|
|
||||||
|
|
||||||
import {General, Preferences} from '../constants';
|
import {General, Preferences} from '../constants';
|
||||||
|
|
||||||
@@ -462,52 +468,33 @@ export function getChannelTimezones(channelId: string): ActionFunc {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchMyChannelsAndMembersREST(teamId: string): ActionFunc {
|
export function fetchMyChannelsAndMembersREST(teamId: string): ActionFunc<{channels: ServerChannel[]; channelMembers: ChannelMembership[]}> {
|
||||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||||
dispatch({
|
|
||||||
type: ChannelTypes.CHANNELS_REQUEST,
|
|
||||||
data: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
let channels;
|
let channels;
|
||||||
let channelMembers;
|
let channelMembers;
|
||||||
const state = getState();
|
|
||||||
const shouldFetchArchived = isMinimumServerVersion(getServerVersion(state), 5, 21);
|
|
||||||
try {
|
try {
|
||||||
[channels, channelMembers] = await Promise.all([
|
[channels, channelMembers] = await Promise.all([
|
||||||
Client4.getMyChannels(teamId, shouldFetchArchived),
|
Client4.getMyChannels(teamId),
|
||||||
Client4.getMyChannelMembers(teamId),
|
Client4.getMyChannelMembers(teamId),
|
||||||
]);
|
]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
forceLogoutIfNecessary(error, dispatch, getState);
|
forceLogoutIfNecessary(error, dispatch, getState);
|
||||||
dispatch({type: ChannelTypes.CHANNELS_FAILURE, error});
|
|
||||||
dispatch(logError(error));
|
dispatch(logError(error));
|
||||||
return {error};
|
return {error: error as ServerError};
|
||||||
}
|
}
|
||||||
|
|
||||||
const {currentUserId} = state.entities.users;
|
|
||||||
const {currentChannelId} = state.entities.channels;
|
|
||||||
|
|
||||||
dispatch(batchActions([
|
dispatch(batchActions([
|
||||||
{
|
{
|
||||||
type: ChannelTypes.RECEIVED_CHANNELS,
|
type: ChannelTypes.RECEIVED_CHANNELS,
|
||||||
teamId,
|
teamId,
|
||||||
data: channels,
|
data: channels,
|
||||||
currentChannelId,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: ChannelTypes.CHANNELS_SUCCESS,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS,
|
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS,
|
||||||
data: channelMembers,
|
data: channelMembers,
|
||||||
sync: !shouldFetchArchived,
|
|
||||||
channels,
|
|
||||||
remove: getChannelsIdForTeam(state, teamId),
|
|
||||||
currentUserId,
|
|
||||||
currentChannelId,
|
|
||||||
},
|
},
|
||||||
]));
|
]));
|
||||||
|
|
||||||
const roles = new Set<string>();
|
const roles = new Set<string>();
|
||||||
for (const member of channelMembers) {
|
for (const member of channelMembers) {
|
||||||
for (const role of member.roles.split(' ')) {
|
for (const role of member.roles.split(' ')) {
|
||||||
@@ -518,7 +505,7 @@ export function fetchMyChannelsAndMembersREST(teamId: string): ActionFunc {
|
|||||||
dispatch(loadRolesIfNeeded(roles));
|
dispatch(loadRolesIfNeeded(roles));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {data: {channels, members: channelMembers}};
|
return {data: {channels, channelMembers}};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user