diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts index e79f887d35..58f6fb9126 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts @@ -35,7 +35,6 @@ import {getServerVersion} from 'mattermost-redux/selectors/entities/general'; import {getCurrentUserId, getUsers} from 'mattermost-redux/selectors/entities/users'; import {isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences'; -import {removeUserFromList} from 'mattermost-redux/utils/user_utils'; import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers'; import {General} from 'mattermost-redux/constants'; @@ -215,12 +214,10 @@ export function getFilteredUsersStats(options: GetFilteredUsersStatsOpts = {}, u export function getProfiles(page = 0, perPage: number = General.PROFILE_CHUNK_SIZE, options: any = {}): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles: UserProfile[]; try { profiles = await Client4.getProfiles(page, perPage, options); - removeUserFromList(currentUserId, profiles); } catch (error) { forceLogoutIfNecessary(error, dispatch, getState); dispatch(logError(error)); @@ -301,12 +298,10 @@ export function getProfilesByIds(userIds: string[], options?: any): ActionFunc { export function getProfilesByUsernames(usernames: string[]): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles; try { profiles = await Client4.getProfilesByUsernames(usernames); - removeUserFromList(currentUserId, profiles); } catch (error) { forceLogoutIfNecessary(error, dispatch, getState); dispatch(logError(error)); @@ -324,7 +319,6 @@ export function getProfilesByUsernames(usernames: string[]): ActionFunc { export function getProfilesInTeam(teamId: string, page: number, perPage: number = General.PROFILE_CHUNK_SIZE, sort = '', options: any = {}): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles; try { @@ -343,7 +337,7 @@ export function getProfilesInTeam(teamId: string, page: number, perPage: number }, { type: UserTypes.RECEIVED_PROFILES_LIST, - data: removeUserFromList(currentUserId, [...profiles]), + data: profiles, }, ])); @@ -413,7 +407,6 @@ export enum ProfilesInChannelSortBy { export function getProfilesInChannel(channelId: string, page: number, perPage: number = General.PROFILE_CHUNK_SIZE, sort = '', options: {active?: boolean} = {}): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles; try { @@ -432,7 +425,7 @@ export function getProfilesInChannel(channelId: string, page: number, perPage: n }, { type: UserTypes.RECEIVED_PROFILES_LIST, - data: removeUserFromList(currentUserId, [...profiles]), + data: profiles, }, ])); @@ -442,7 +435,6 @@ export function getProfilesInChannel(channelId: string, page: number, perPage: n export function getProfilesInGroupChannels(channelsIds: string[]): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let channelProfiles; try { @@ -466,7 +458,7 @@ export function getProfilesInGroupChannels(channelsIds: string[]): ActionFunc { }, { type: UserTypes.RECEIVED_PROFILES_LIST, - data: removeUserFromList(currentUserId, [...profiles]), + data: profiles, }, ); } @@ -480,7 +472,6 @@ export function getProfilesInGroupChannels(channelsIds: string[]): ActionFunc { export function getProfilesNotInChannel(teamId: string, channelId: string, groupConstrained: boolean, page: number, perPage: number = General.PROFILE_CHUNK_SIZE): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles; try { @@ -501,7 +492,7 @@ export function getProfilesNotInChannel(teamId: string, channelId: string, group }, { type: UserTypes.RECEIVED_PROFILES_LIST, - data: removeUserFromList(currentUserId, [...profiles]), + data: profiles, }, ])); @@ -562,7 +553,6 @@ export function updateMyTermsOfServiceStatus(termsOfServiceId: string, accepted: export function getProfilesInGroup(groupId: string, page = 0, perPage: number = General.PROFILE_CHUNK_SIZE, sort = ''): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles; try { @@ -581,7 +571,7 @@ export function getProfilesInGroup(groupId: string, page = 0, perPage: number = }, { type: UserTypes.RECEIVED_PROFILES_LIST, - data: removeUserFromList(currentUserId, [...profiles]), + data: profiles, }, ])); @@ -591,7 +581,6 @@ export function getProfilesInGroup(groupId: string, page = 0, perPage: number = export function getProfilesNotInGroup(groupId: string, page = 0, perPage: number = General.PROFILE_CHUNK_SIZE): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; let profiles; try { @@ -610,7 +599,7 @@ export function getProfilesNotInGroup(groupId: string, page = 0, perPage: number }, { type: UserTypes.RECEIVED_PROFILES_LIST, - data: removeUserFromList(currentUserId, [...profiles]), + data: profiles, }, ])); @@ -842,9 +831,6 @@ export function autocompleteUsers(term: string, teamId = '', channelId = '', opt }): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { dispatch({type: UserTypes.AUTOCOMPLETE_USERS_REQUEST, data: null}); - - const {currentUserId} = getState().entities.users; - let data; try { data = await Client4.autocompleteUsers(term, teamId, channelId, options); @@ -859,7 +845,6 @@ export function autocompleteUsers(term: string, teamId = '', channelId = '', opt if (data.out_of_channel) { users = [...users, ...data.out_of_channel]; } - removeUserFromList(currentUserId, users); const actions: AnyAction[] = [{ type: UserTypes.RECEIVED_PROFILES_LIST, data: users, @@ -902,8 +887,6 @@ export function autocompleteUsers(term: string, teamId = '', channelId = '', opt export function searchProfiles(term: string, options: any = {}): ActionFunc { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { - const {currentUserId} = getState().entities.users; - let profiles; try { profiles = await Client4.searchUsers(term, options); @@ -913,7 +896,7 @@ export function searchProfiles(term: string, options: any = {}): ActionFunc { return {error}; } - const actions: AnyAction[] = [{type: UserTypes.RECEIVED_PROFILES_LIST, data: removeUserFromList(currentUserId, [...profiles])}]; + const actions: AnyAction[] = [{type: UserTypes.RECEIVED_PROFILES_LIST, data: profiles}]; if (options.in_channel_id) { actions.push({