MM-51359 Replace makeGetUserTimezone selector with getCurrentTimezone and similar selectors (#22832)

Этот коммит содержится в:
Harrison Healey
2023-04-05 14:57:19 -04:00
коммит произвёл GitHub
родитель 7029d88443
Коммит 54af9a7c7d
23 изменённых файлов: 219 добавлений и 227 удалений

Просмотреть файл

@@ -1,13 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createSelector} from 'reselect';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/common';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getTimezoneForUserProfile} from 'mattermost-redux/selectors/entities/timezone';
import * as UserAgent from 'utils/user_agent';
import type {GlobalState} from 'types/store';
@@ -17,15 +11,6 @@ declare global {
}
}
export function areTimezonesEnabledAndSupported(state: GlobalState) {
if (UserAgent.isInternetExplorer()) {
return false;
}
const config = getConfig(state);
return config.ExperimentalTimezone === 'true';
}
export function getBasePath(state: GlobalState) {
const config = getConfig(state) || {};
@@ -36,21 +21,6 @@ export function getBasePath(state: GlobalState) {
return window.basename || '/';
}
export const getCurrentUserTimezone = createSelector(
'getCurrentUserTimezone',
getCurrentUser,
areTimezonesEnabledAndSupported,
(user, enabledTimezone) => {
let timezone;
if (enabledTimezone) {
const userTimezone = getTimezoneForUserProfile(user);
timezone = userTimezone.useAutomaticTimezone ? userTimezone.automaticTimezone : userTimezone.manualTimezone;
}
return timezone;
},
);
export function getConnectionId(state: GlobalState) {
return state.websocket.connectionId;
}

Просмотреть файл

@@ -5,6 +5,7 @@ import moment from 'moment-timezone';
import {createSelector} from 'reselect';
import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone';
import {getCurrentUser, getUser} from 'mattermost-redux/selectors/entities/users';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
@@ -15,7 +16,6 @@ import {CustomStatusDuration, UserCustomStatus} from '@mattermost/types/users';
import {isDateWithinDaysRange, TimeInformation} from 'utils/utils';
import {GlobalState} from 'types/store';
import {getCurrentUserTimezone} from 'selectors/general';
import {getCurrentMomentForTimezone} from 'utils/timezone';
export function makeGetCustomStatus(): (state: GlobalState, userID?: string) => UserCustomStatus {
@@ -39,7 +39,7 @@ export function isCustomStatusExpired(state: GlobalState, customStatus?: UserCus
}
const expiryTime = moment(customStatus.expires_at);
const timezone = getCurrentUserTimezone(state);
const timezone = getCurrentTimezone(state);
const currentTime = getCurrentMomentForTimezone(timezone);
return currentTime.isSameOrAfter(expiryTime);
}