From 76e278a13de936c09068ad1c2c2a16be0c419249 Mon Sep 17 00:00:00 2001 From: Stas Vovk Date: Wed, 14 Oct 2015 20:36:12 +0300 Subject: added display tab under account settings. added 24h time option --- web/react/utils/constants.jsx | 3 ++- web/react/utils/utils.jsx | 33 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index cee2ec114..3b7f16369 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -288,6 +288,7 @@ module.exports = { } ], Preferences: { - CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show' + CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show', + CATEGORY_DISPLAY_SETTINGS: 'display_settings' } }; diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 8f697a9c5..a5057b5ca 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -4,6 +4,7 @@ var AppDispatcher = require('../dispatcher/app_dispatcher.jsx'); var ChannelStore = require('../stores/channel_store.jsx'); var UserStore = require('../stores/user_store.jsx'); +var PreferenceStore = require('../stores/preference_store.jsx'); var TeamStore = require('../stores/team_store.jsx'); var Constants = require('../utils/constants.jsx'); var ActionTypes = Constants.ActionTypes; @@ -164,23 +165,29 @@ export function displayDate(ticks) { } export function displayTime(ticks) { - var d = new Date(ticks); - var hours = d.getHours(); - var minutes = d.getMinutes(); - - var ampm = 'AM'; - if (hours >= 12) { - ampm = 'PM'; - } + const d = new Date(ticks); + let hours = d.getHours(); + let minutes = d.getMinutes(); + let ampm = ''; - hours = hours % 12; - if (!hours) { - hours = '12'; - } if (minutes <= 9) { minutes = '0' + minutes; } - return hours + ':' + minutes + ' ' + ampm; + + const useMilitaryTime = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', {value: 'false'}).value; + if(useMilitaryTime === 'false') { + ampm = ' AM'; + if (hours >= 12) { + ampm = ' PM'; + } + + hours = hours % 12; + if (!hours) { + hours = '12'; + } + } + + return hours + ':' + minutes + ampm; } export function displayDateTime(ticks) { -- cgit v1.2.3-1-g7c22 From 440faabc604fa6763515efd9009a7c276e140f09 Mon Sep 17 00:00:00 2001 From: Stas Vovk Date: Thu, 15 Oct 2015 00:05:39 +0300 Subject: fixed style guide error --- web/react/utils/utils.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index a5057b5ca..8f01b3e33 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -175,7 +175,7 @@ export function displayTime(ticks) { } const useMilitaryTime = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', {value: 'false'}).value; - if(useMilitaryTime === 'false') { + if (useMilitaryTime === 'false') { ampm = ' AM'; if (hours >= 12) { ampm = ' PM'; -- cgit v1.2.3-1-g7c22 From 327b0b5a2119ae888c812f682b3934061b8f59bf Mon Sep 17 00:00:00 2001 From: hmhealey Date: Thu, 15 Oct 2015 15:09:40 -0400 Subject: Added an initial call to get all user preferences on page load --- web/react/utils/async_client.jsx | 15 +++++++-------- web/react/utils/client.jsx | 13 +++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index 1bf8a6fee..b22d7237e 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -638,16 +638,15 @@ export function getMyTeam() { ); } -export function getDirectChannelPreferences() { - if (isCallInProgress('getDirectChannelPreferences')) { +export function getAllPreferences() { + if (isCallInProgress('getAllPreferences')) { return; } - callTracker.getDirectChannelPreferences = utils.getTimestamp(); - client.getPreferenceCategory( - Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, + callTracker.getAllPreferences = utils.getTimestamp(); + client.getAllPreferences( (data, textStatus, xhr) => { - callTracker.getDirectChannelPreferences = 0; + callTracker.getAllPreferences = 0; if (xhr.status === 304 || !data) { return; @@ -659,8 +658,8 @@ export function getDirectChannelPreferences() { }); }, (err) => { - callTracker.getDirectChannelPreferences = 0; - dispatchError(err, 'getDirectChannelPreferences'); + callTracker.getAllPreferences = 0; + dispatchError(err, 'getAllPreferences'); } ); } diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 76a402855..f6aee362c 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -1142,6 +1142,19 @@ export function listIncomingHooks(success, error) { }); } +export function getAllPreferences(success, error) { + $.ajax({ + url: `/api/v1/preferences/`, + dataType: 'json', + type: 'GET', + success, + error: (xhr, status, err) => { + var e = handleError('getAllPreferences', xhr, status, err); + error(e); + } + }); +} + export function getPreferenceCategory(category, success, error) { $.ajax({ url: `/api/v1/preferences/${category}`, -- cgit v1.2.3-1-g7c22 From 551b07960ed8ec36c24341f96f2b06fee25ceab3 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Thu, 15 Oct 2015 02:13:48 +0200 Subject: PLT-74: Enable Up Arrow keyboard shortcut to edit your last message --- web/react/utils/constants.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'web/react/utils') diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index cee2ec114..b8200db54 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -17,6 +17,7 @@ module.exports = { RECIEVED_POSTS: null, RECIEVED_POST: null, + RECIEVED_EDIT_POST: null, RECIEVED_SEARCH: null, RECIEVED_POST_SELECTED: null, RECIEVED_MENTION_DATA: null, @@ -289,5 +290,14 @@ module.exports = { ], Preferences: { CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show' + }, + KeyCodes: { + UP: 38, + DOWN: 40, + LEFT: 37, + RIGHT: 39, + BACKSPACE: 8, + ENTER: 13, + ESCAPE: 27 } }; -- cgit v1.2.3-1-g7c22