UNPKG

mattermost-redux

Version:

Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client

40 lines (39 loc) 2.02 kB
"use strict"; // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCurrentTimezoneLabel = exports.getCurrentTimezone = exports.getCurrentTimezoneFull = exports.getTimezoneForUserProfile = void 0; exports.generateCurrentTimezoneLabel = generateCurrentTimezoneLabel; const timezones_json_1 = __importDefault(require("timezones.json")); const create_selector_1 = require("mattermost-redux/selectors/create_selector"); const timezone_utils_1 = require("mattermost-redux/utils/timezone_utils"); const common_1 = require("./common"); exports.getTimezoneForUserProfile = (0, create_selector_1.createSelector)('getTimezoneForUserProfile', (profile) => profile, (profile) => { if (profile && profile.timezone) { return { ...profile.timezone, useAutomaticTimezone: profile.timezone.useAutomaticTimezone === 'true', }; } return { useAutomaticTimezone: true, automaticTimezone: '', manualTimezone: '', }; }); exports.getCurrentTimezoneFull = (0, create_selector_1.createSelector)('getCurrentTimezoneFull', common_1.getCurrentUser, (currentUser) => { return (0, exports.getTimezoneForUserProfile)(currentUser); }); exports.getCurrentTimezone = (0, create_selector_1.createSelector)('getCurrentTimezone', exports.getCurrentTimezoneFull, (timezoneFull) => { return (0, timezone_utils_1.getUserCurrentTimezone)(timezoneFull); }); function generateCurrentTimezoneLabel(timezone) { if (!timezone) { return ''; } return (0, timezone_utils_1.getTimezoneLabel)(timezones_json_1.default, timezone); } exports.getCurrentTimezoneLabel = (0, create_selector_1.createSelector)('getCurrentTimezoneLabel', exports.getCurrentTimezone, generateCurrentTimezoneLabel);