diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:56:37 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:56:37 -0400 |
commit | 975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165 (patch) | |
tree | a0852f9faf6de9962b5478ed3f1bbaccd71062c0 /web/react/utils/utils.jsx | |
parent | 160e1a8bea6d8280ef3b41a4a9f80674b75f3eb0 (diff) | |
parent | d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 (diff) | |
download | chat-975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165.tar.gz chat-975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165.tar.bz2 chat-975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165.zip |
Merge pull request #2331 from mattermost/plt-1680
PLT-1680 Converting client to react-router. Stage 1
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r-- | web/react/utils/utils.jsx | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 6942a8e08..88777164b 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -2,9 +2,10 @@ // See License.txt for license information. import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; -import * as EventHelpers from '../dispatcher/event_helpers.jsx'; +import * as GlobalActions from '../action_creators/global_actions.jsx'; import ChannelStore from '../stores/channel_store.jsx'; import UserStore from '../stores/user_store.jsx'; +import LocalizationStore from '../stores/localization_store.jsx'; import PreferenceStore from '../stores/preference_store.jsx'; import TeamStore from '../stores/team_store.jsx'; import Constants from '../utils/constants.jsx'; @@ -941,7 +942,7 @@ export function updateAddressBar(channelName) { } export function switchChannel(channel) { - EventHelpers.emitChannelClickEvent(channel); + GlobalActions.emitChannelClickEvent(channel); updateAddressBar(channel.name); @@ -1130,8 +1131,8 @@ export function fileSizeToString(bytes) { // Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server. export function getFileUrl(filename, isDownload) { - const downloadParam = isDownload ? '&download=1' : ''; - return getWindowLocationOrigin() + '/api/v1/files/get' + filename + '?' + getSessionIndex() + downloadParam; + const downloadParam = isDownload ? '?download=1' : ''; + return getWindowLocationOrigin() + '/api/v1/files/get' + filename + downloadParam; } // Gets the name of a file (including extension) from a given url or file path. @@ -1151,14 +1152,6 @@ export function getWebsocketPort(protocol) { return ''; } -export function getSessionIndex() { - if (global.window.mm_session_token_index >= 0) { - return 'session_token_index=' + global.window.mm_session_token_index; - } - - return ''; -} - // Generates a RFC-4122 version 4 compliant globally unique identifier. export function generateId() { // implementation taken from http://stackoverflow.com/a/2117523 @@ -1405,3 +1398,19 @@ export function isPostEphemeral(post) { export function getRootId(post) { return post.root_id === '' ? post.id : post.root_id; } + +export function localizeMessage(id, defaultMessage) { + const translations = LocalizationStore.getTranslations(); + if (translations) { + const value = translations[id]; + if (value) { + return value; + } + } + + if (defaultMessage) { + return defaultMessage; + } + + return id; +} |