mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Revert "[MM-52546] webapp/channels : Update current user and status on WebSocket reconnect (#23071)"
This reverts commit 6d3354266a.
This commit is contained in:
@@ -234,7 +234,7 @@ export function reconnect() {
|
||||
// we can request for getPosts again when socket is connected
|
||||
dispatch(getPosts(currentChannelId));
|
||||
}
|
||||
dispatch(StatusActions.loadStatusesForChannelAndSidebar());
|
||||
StatusActions.loadStatusesForChannelAndSidebar();
|
||||
|
||||
const crtEnabled = isCollapsedThreadsEnabled(state);
|
||||
dispatch(TeamActions.getMyTeamUnreads(crtEnabled, true));
|
||||
|
||||
@@ -280,10 +280,12 @@ export function getMissingProfilesByUsernames(usernames: string[]): ActionFunc {
|
||||
|
||||
export function getProfilesByIds(userIds: string[], options?: any): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
const {currentUserId} = getState().entities.users;
|
||||
let profiles: UserProfile[];
|
||||
|
||||
try {
|
||||
profiles = await Client4.getProfilesByIds(userIds, options);
|
||||
removeUserFromList(currentUserId, profiles);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch, getState);
|
||||
dispatch(logError(error));
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
import {UserTypes, ChannelTypes} from 'mattermost-redux/action_types';
|
||||
import {GenericAction} from 'mattermost-redux/types/actions';
|
||||
import reducer from 'mattermost-redux/reducers/entities/users';
|
||||
|
||||
import {TestHelper} from 'utils/test_helper';
|
||||
|
||||
type ReducerState = ReturnType<typeof reducer>;
|
||||
|
||||
describe('Reducers.users', () => {
|
||||
@@ -676,35 +673,4 @@ describe('Reducers.users', () => {
|
||||
expect(newState.profilesNotInGroup).toEqual(expectedState.profilesNotInGroup);
|
||||
});
|
||||
});
|
||||
describe('profiles', () => {
|
||||
it('UserTypes.RECEIVED_PROFILES_LIST, should merge existing users with new ones', () => {
|
||||
const firstUser = TestHelper.getUserMock({id: 'first_user_id'});
|
||||
const secondUser = TestHelper.getUserMock({id: 'seocnd_user_id'});
|
||||
const thirdUser = TestHelper.getUserMock({id: 'third_user_id'});
|
||||
const partialUpdatedFirstUser = {
|
||||
...firstUser,
|
||||
update_at: 123456789,
|
||||
};
|
||||
Reflect.deleteProperty(partialUpdatedFirstUser, 'email');
|
||||
Reflect.deleteProperty(partialUpdatedFirstUser, 'notify_props');
|
||||
const state = {
|
||||
profiles: {
|
||||
first_user_id: firstUser,
|
||||
second_user_id: secondUser,
|
||||
},
|
||||
};
|
||||
const action = {
|
||||
type: UserTypes.RECEIVED_PROFILES_LIST,
|
||||
data: [
|
||||
partialUpdatedFirstUser,
|
||||
thirdUser,
|
||||
],
|
||||
};
|
||||
const {profiles: newProfiles} = reducer(state as unknown as ReducerState, action);
|
||||
|
||||
expect(newProfiles.first_user_id).toEqual({...firstUser, ...partialUpdatedFirstUser});
|
||||
expect(newProfiles.second_user_id).toEqual(secondUser);
|
||||
expect(newProfiles.third_user_id).toEqual(thirdUser);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -198,18 +198,15 @@ function profiles(state: IDMappedObjects<UserProfile> = {}, action: GenericActio
|
||||
const users: UserProfile[] = action.data;
|
||||
|
||||
return users.reduce((nextState, user) => {
|
||||
const oldUser = nextState[user.id] || {};
|
||||
const oldUser = nextState[user.id];
|
||||
|
||||
if (isEqual(user, oldUser)) {
|
||||
if (oldUser && isEqual(user, oldUser)) {
|
||||
return nextState;
|
||||
}
|
||||
|
||||
return {
|
||||
...nextState,
|
||||
[user.id]: {
|
||||
...oldUser,
|
||||
...user,
|
||||
},
|
||||
[user.id]: user,
|
||||
};
|
||||
}, state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user