* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {getCurrentUser} from '@mm-redux/selectors/entities/users';
|
|
import {getUserTimezone} from '@mm-redux/selectors/entities/timezone';
|
|
import {updateMe} from './users';
|
|
import {DispatchFunc, GetStateFunc} from '@mm-redux/types/actions';
|
|
export function autoUpdateTimezone(deviceTimezone: string) {
|
|
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
|
const currentUer = getCurrentUser(getState());
|
|
const currentTimezone = getUserTimezone(getState(), currentUer.id);
|
|
const newTimezoneExists = currentTimezone.automaticTimezone !== deviceTimezone;
|
|
|
|
if (currentTimezone.useAutomaticTimezone && newTimezoneExists) {
|
|
const timezone = {
|
|
useAutomaticTimezone: 'true',
|
|
automaticTimezone: deviceTimezone,
|
|
manualTimezone: currentTimezone.manualTimezone,
|
|
};
|
|
|
|
const updatedUser = {
|
|
...currentUer,
|
|
timezone,
|
|
};
|
|
|
|
updateMe(updatedUser)(dispatch, getState);
|
|
}
|
|
};
|
|
}
|