[MM-60303] Changing status in mobile app doesn't change your status in the webapp (#28246)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
040838b056
Коммит
a03972e502
@@ -87,26 +87,26 @@ describe('actions/status_actions', () => {
|
||||
test('load statuses with posts in channel and user in sidebar', () => {
|
||||
const state = cloneDeep(initialState);
|
||||
const testStore = mockStore(state);
|
||||
testStore.dispatch(Actions.addVisibleUsersInCurrentChannelToStatusPoll());
|
||||
testStore.dispatch(Actions.addVisibleUsersInCurrentChannelAndSelfToStatusPoll());
|
||||
expect(addUserIdsForStatusFetchingPoll).toHaveBeenCalled();
|
||||
expect(addUserIdsForStatusFetchingPoll).toHaveBeenCalledWith(['user_id2', 'user_id3']);
|
||||
expect(addUserIdsForStatusFetchingPoll).toHaveBeenCalledWith(['user_id2', 'user_id3', 'current_user_id']);
|
||||
});
|
||||
|
||||
test('load statuses with empty channel and user in sidebar', () => {
|
||||
const state = cloneDeep(initialState);
|
||||
state.entities.channels.currentChannelId = 'channel_id2';
|
||||
const testStore = mockStore(state);
|
||||
testStore.dispatch(Actions.addVisibleUsersInCurrentChannelToStatusPoll());
|
||||
expect(addUserIdsForStatusFetchingPoll).toHaveBeenCalledWith(['user_id3']);
|
||||
testStore.dispatch(Actions.addVisibleUsersInCurrentChannelAndSelfToStatusPoll());
|
||||
expect(addUserIdsForStatusFetchingPoll).toHaveBeenCalledWith(['user_id3', 'current_user_id']);
|
||||
});
|
||||
|
||||
test('load statuses with empty channel and no users in sidebar', () => {
|
||||
test('load statuses with empty channel and no users in sidebar, should only fetch current user\'s status', () => {
|
||||
const state = cloneDeep(initialState);
|
||||
state.entities.channels.currentChannelId = 'channel_id2';
|
||||
state.entities.preferences.myPreferences = {};
|
||||
const testStore = mockStore(state);
|
||||
testStore.dispatch(Actions.addVisibleUsersInCurrentChannelToStatusPoll());
|
||||
expect(addUserIdsForStatusFetchingPoll).not.toHaveBeenCalled();
|
||||
testStore.dispatch(Actions.addVisibleUsersInCurrentChannelAndSelfToStatusPoll());
|
||||
expect(addUserIdsForStatusFetchingPoll).toHaveBeenCalledWith(['current_user_id']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -17,10 +17,12 @@ import {loadCustomEmojisForCustomStatusesByUserIds} from 'actions/emoji_actions'
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
/**
|
||||
* Adds all the visible users of the current channel i.e users who have recently posted in the current channel
|
||||
* and users who have DMs open with the current user to the status pool for fetching their statuses.
|
||||
* Adds the following users to the status pool for fetching their statuses:
|
||||
* - All users of current channel with recent posts.
|
||||
* - All users who have DMs open with the current user.
|
||||
* - The current user.
|
||||
*/
|
||||
export function addVisibleUsersInCurrentChannelToStatusPoll(): ActionFunc<boolean, GlobalState> {
|
||||
export function addVisibleUsersInCurrentChannelAndSelfToStatusPoll(): ActionFunc<boolean, GlobalState> {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const currentUserId = getCurrentUserId(state);
|
||||
@@ -49,6 +51,9 @@ export function addVisibleUsersInCurrentChannelToStatusPoll(): ActionFunc<boolea
|
||||
}
|
||||
}
|
||||
|
||||
// Add current user to the list to fetch status for
|
||||
userIdsToFetchStatusFor.add(currentUserId);
|
||||
|
||||
// Both the users in the DM list and recent posts constitute for all the visible users in the current channel
|
||||
const userIdsForStatus = Array.from(userIdsToFetchStatusFor);
|
||||
if (userIdsForStatus.length > 0) {
|
||||
|
||||
@@ -246,7 +246,7 @@ export function reconnect() {
|
||||
|
||||
const enabledUserStatuses = getIsUserStatusesConfigEnabled(state);
|
||||
if (enabledUserStatuses) {
|
||||
dispatch(StatusActions.addVisibleUsersInCurrentChannelToStatusPoll());
|
||||
dispatch(StatusActions.addVisibleUsersInCurrentChannelAndSelfToStatusPoll());
|
||||
}
|
||||
|
||||
const crtEnabled = isCollapsedThreadsEnabled(state);
|
||||
|
||||
@@ -26,7 +26,7 @@ jest.mock('components/product_notices_modal', () => () => <div/>);
|
||||
jest.mock('plugins/pluggable', () => () => <div/>);
|
||||
|
||||
jest.mock('actions/status_actions', () => ({
|
||||
addVisibleUsersInCurrentChannelToStatusPoll: jest.fn().mockImplementation(() => () => {}),
|
||||
addVisibleUsersInCurrentChannelAndSelfToStatusPoll: jest.fn().mockImplementation(() => () => {}),
|
||||
}));
|
||||
|
||||
jest.mock('mattermost-redux/selectors/entities/general', () => ({
|
||||
@@ -50,7 +50,7 @@ describe('ChannelController', () => {
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
it('dispatches addVisibleUsersInCurrentChannelToStatusPoll when enableUserStatuses is true', () => {
|
||||
it('dispatches addVisibleUsersInCurrentChannelAndSelfToStatusPoll when enableUserStatuses is true', () => {
|
||||
mockState.entities.general.config.EnableUserStatuses = 'true';
|
||||
const store = mockStore(mockState);
|
||||
|
||||
@@ -64,10 +64,10 @@ describe('ChannelController', () => {
|
||||
jest.advanceTimersByTime(Constants.STATUS_INTERVAL);
|
||||
});
|
||||
|
||||
expect(actions.addVisibleUsersInCurrentChannelToStatusPoll).toHaveBeenCalled();
|
||||
expect(actions.addVisibleUsersInCurrentChannelAndSelfToStatusPoll).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not dispatch addVisibleUsersInCurrentChannelToStatusPoll when enableUserStatuses is false', () => {
|
||||
it('does not dispatch addVisibleUsersInCurrentChannelAndSelfToStatusPoll when enableUserStatuses is false', () => {
|
||||
const store = mockStore(mockState);
|
||||
mockState.entities.general.config.EnableUserStatuses = 'false';
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('ChannelController', () => {
|
||||
jest.advanceTimersByTime(Constants.STATUS_INTERVAL);
|
||||
});
|
||||
|
||||
expect(actions.addVisibleUsersInCurrentChannelToStatusPoll).not.toHaveBeenCalled();
|
||||
expect(actions.addVisibleUsersInCurrentChannelAndSelfToStatusPoll).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {useDispatch, useSelector} from 'react-redux';
|
||||
import {cleanUpStatusAndProfileFetchingPoll} from 'mattermost-redux/actions/status_profile_polling';
|
||||
import {getIsUserStatusesConfigEnabled} from 'mattermost-redux/selectors/entities/common';
|
||||
|
||||
import {addVisibleUsersInCurrentChannelToStatusPoll} from 'actions/status_actions';
|
||||
import {addVisibleUsersInCurrentChannelAndSelfToStatusPoll} from 'actions/status_actions';
|
||||
|
||||
import {makeAsyncComponent} from 'components/async_load';
|
||||
import CenterChannel from 'components/channel_layout/center_channel';
|
||||
@@ -51,11 +51,13 @@ export default function ChannelController(props: Props) {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Starts a regular interval to fetch statuses of users.
|
||||
// see function "addVisibleUsersInCurrentChannelAndSelfToStatusPoll" for more details on which user's statuses are fetched.
|
||||
useEffect(() => {
|
||||
let loadStatusesIntervalId: NodeJS.Timeout;
|
||||
if (enabledUserStatuses) {
|
||||
loadStatusesIntervalId = setInterval(() => {
|
||||
dispatch(addVisibleUsersInCurrentChannelToStatusPoll());
|
||||
dispatch(addVisibleUsersInCurrentChannelAndSelfToStatusPoll());
|
||||
}, Constants.STATUS_INTERVAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {isCustomGroupsEnabled} from 'mattermost-redux/selectors/entities/prefere
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionFuncAsync} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {addVisibleUsersInCurrentChannelToStatusPoll} from 'actions/status_actions';
|
||||
import {addVisibleUsersInCurrentChannelAndSelfToStatusPoll} from 'actions/status_actions';
|
||||
import {addUserToTeam} from 'actions/team_actions';
|
||||
import LocalStorageStore from 'stores/local_storage_store';
|
||||
|
||||
@@ -41,7 +41,7 @@ export function initializeTeam(team: Team): ActionFuncAsync<Team, GlobalState> {
|
||||
|
||||
const enabledUserStatuses = getIsUserStatusesConfigEnabled(state);
|
||||
if (enabledUserStatuses) {
|
||||
dispatch(addVisibleUsersInCurrentChannelToStatusPoll());
|
||||
dispatch(addVisibleUsersInCurrentChannelAndSelfToStatusPoll());
|
||||
}
|
||||
|
||||
const license = getLicense(state);
|
||||
|
||||
Ссылка в новой задаче
Block a user