diff options
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/constants.jsx | 5 | ||||
-rw-r--r-- | web/react/utils/text_formatting.jsx | 8 | ||||
-rw-r--r-- | web/react/utils/utils.jsx | 15 |
3 files changed, 25 insertions, 3 deletions
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index c1bd41b88..d78776aa3 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -464,8 +464,9 @@ export default { }, OVERLAY_TIME_DELAY: 400, MIN_USERNAME_LENGTH: 3, - MAX_USERNAME_LENGTH: 15, + MAX_USERNAME_LENGTH: 64, MIN_PASSWORD_LENGTH: 5, MAX_PASSWORD_LENGTH: 50, - TIME_SINCE_UPDATE_INTERVAL: 30000 + TIME_SINCE_UPDATE_INTERVAL: 30000, + MIN_HASHTAG_LINK_LENGTH: 3 }; diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx index e837ded53..dae2252a6 100644 --- a/web/react/utils/text_formatting.jsx +++ b/web/react/utils/text_formatting.jsx @@ -248,8 +248,14 @@ function autolinkHashtags(text, tokens) { const index = tokens.size; const alias = `MM_HASHTAG${index}`; + let value = hashtag; + + if (hashtag.length > Constants.MIN_HASHTAG_LINK_LENGTH) { + value = `<a class='mention-link' href='#' data-hashtag='${hashtag}'>${hashtag}</a>`; + } + tokens.set(alias, { - value: `<a class='mention-link' href='#' data-hashtag='${hashtag}'>${hashtag}</a>`, + value, originalText: hashtag }); diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 6bb7baa64..4beec8d64 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -14,6 +14,8 @@ import * as AsyncClient from './async_client.jsx'; import * as client from './client.jsx'; import Autolinker from 'autolinker'; +import {FormattedTime} from 'mm-intl'; + export function isEmail(email) { // writing a regex to match all valid email addresses is really, really hard (see http://stackoverflow.com/a/201378) // so we just do a simple check and rely on a verification email to tell if it's a real address @@ -245,6 +247,19 @@ export function displayTime(ticks, utc) { return hours + ':' + minutes + ampm + timezone; } +export function displayTimeFormatted(ticks) { + const useMilitaryTime = PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time'); + + return ( + <FormattedTime + value={ticks} + hour='numeric' + minute='numeric' + hour12={!useMilitaryTime} + /> + ); +} + export function displayDateTime(ticks) { var seconds = Math.floor((Date.now() - ticks) / 1000); |