Revert "[MM-52546] webapp/channels : Update current user and status on WebSocket reconnect (#23071)"

This reverts commit 6d3354266a.
This commit is contained in:
Harrison Healey
2023-06-29 17:21:36 -04:00
parent 8f96888b1a
commit 69ee162a6e
4 changed files with 6 additions and 41 deletions

View File

@@ -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));

View File

@@ -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));

View File

@@ -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);
});
});
});

View File

@@ -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);
}