summaryrefslogtreecommitdiffstats
path: root/webapp/utils
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/utils')
-rw-r--r--webapp/utils/async_client.jsx30
-rw-r--r--webapp/utils/constants.jsx13
-rw-r--r--webapp/utils/emoticons.jsx18
-rw-r--r--webapp/utils/text_formatting.jsx2
-rw-r--r--webapp/utils/utils.jsx12
-rw-r--r--webapp/utils/web_client.jsx4
6 files changed, 46 insertions, 33 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index 6535c024d..7ddf299f6 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -47,7 +47,21 @@ function isCallInProgress(callName) {
return true;
}
-export function getChannels(checkVersion) {
+export function checkVersion() {
+ var serverVersion = Client.getServerVersion();
+
+ if (serverVersion !== BrowserStore.getLastServerVersion()) {
+ if (!BrowserStore.getLastServerVersion() || BrowserStore.getLastServerVersion() === '') {
+ BrowserStore.setLastServerVersion(serverVersion);
+ } else {
+ BrowserStore.setLastServerVersion(serverVersion);
+ window.location.reload(true);
+ console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
+ }
+ }
+}
+
+export function getChannels(doVersionCheck) {
if (isCallInProgress('getChannels')) {
return null;
}
@@ -58,18 +72,8 @@ export function getChannels(checkVersion) {
(data) => {
callTracker.getChannels = 0;
- if (checkVersion) {
- var serverVersion = Client.getServerVersion();
-
- if (serverVersion !== BrowserStore.getLastServerVersion()) {
- if (!BrowserStore.getLastServerVersion() || BrowserStore.getLastServerVersion() === '') {
- BrowserStore.setLastServerVersion(serverVersion);
- } else {
- BrowserStore.setLastServerVersion(serverVersion);
- window.location.reload(true);
- console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
- }
- }
+ if (doVersionCheck) {
+ checkVersion();
}
AppDispatcher.handleServerAction({
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index 109291d1f..e5d927ec1 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -249,7 +249,8 @@ export default {
RESERVED_USERNAMES: [
'valet',
'all',
- 'channel'
+ 'channel',
+ 'here'
],
MONTHS: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
MAX_DMS: 20,
@@ -530,7 +531,11 @@ export default {
CHANNEL_DISPLAY_MODE: 'channel_display_mode',
CHANNEL_DISPLAY_MODE_CENTERED: 'centered',
CHANNEL_DISPLAY_MODE_FULL_SCREEN: 'full',
- CHANNEL_DISPLAY_MODE_DEFAULT: 'centered'
+ CHANNEL_DISPLAY_MODE_DEFAULT: 'centered',
+ MESSAGE_DISPLAY: 'message_display',
+ MESSAGE_DISPLAY_CLEAN: 'clean',
+ MESSAGE_DISPLAY_COMPACT: 'compact',
+ MESSAGE_DISPLAY_DEFAULT: 'clean'
},
TutorialSteps: {
INTRO_SCREENS: 0,
@@ -548,7 +553,9 @@ export default {
ESCAPE: 27,
SPACE: 32,
TAB: 9,
- U: 85
+ U: 85,
+ A: 65,
+ M: 77
},
CODE_PREVIEW_MAX_FILE_SIZE: 500000, // 500 KB
HighlightedLanguages: {
diff --git a/webapp/utils/emoticons.jsx b/webapp/utils/emoticons.jsx
index 505e10c19..35c7dba04 100644
--- a/webapp/utils/emoticons.jsx
+++ b/webapp/utils/emoticons.jsx
@@ -1,8 +1,6 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import $ from 'jquery';
-
import Constants from './constants.jsx';
import emojis from './emoji.json';
@@ -134,7 +132,7 @@ export function getEmoticonsByCodePoint() {
export function handleEmoticons(text, tokens) {
let output = text;
- function replaceEmoticonWithToken(fullMatch, prefix, matchText, name) {
+ function replaceEmoticonWithToken(fullMatch, matchText, name) {
if (getEmoticonsByName().has(name)) {
const index = tokens.size;
const alias = `MM_EMOTICON${index}`;
@@ -145,19 +143,23 @@ export function handleEmoticons(text, tokens) {
originalText: fullMatch
});
- return prefix + alias;
+ return alias;
}
return fullMatch;
}
- output = output.replace(/(^|\s)(:([a-zA-Z0-9_-]+):)(?=$|\s)/g, (fullMatch, prefix, matchText, name) => replaceEmoticonWithToken(fullMatch, prefix, matchText, name));
+ // match named emoticons like :goat:
+ output = output.replace(/(:([a-zA-Z0-9_-]+):)/g, (fullMatch, matchText, name) => replaceEmoticonWithToken(fullMatch, matchText, name));
+
+ // match text smilies like :D
+ for (const name of Object.keys(emoticonPatterns)) {
+ const pattern = emoticonPatterns[name];
- $.each(emoticonPatterns, (name, pattern) => {
// this might look a bit funny, but since the name isn't contained in the actual match
// like with the named emoticons, we need to add it in manually
- output = output.replace(pattern, (fullMatch, prefix, matchText) => replaceEmoticonWithToken(fullMatch, prefix, matchText, name));
- });
+ output = output.replace(pattern, (fullMatch, matchText) => replaceEmoticonWithToken(fullMatch, matchText, name));
+ }
return output;
}
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx
index 96b51d632..623fe0660 100644
--- a/webapp/utils/text_formatting.jsx
+++ b/webapp/utils/text_formatting.jsx
@@ -318,7 +318,7 @@ function parseSearchTerms(searchTerm) {
termString = termString.substring(captured[0].length);
// break the text up into words based on how the server splits them in SqlPostStore.SearchPosts and then discard empty terms
- terms.push(...captured[0].split(/[ <>+\-\(\)\~\@]/).filter((term) => !!term));
+ terms.push(...captured[0].split(/[ <>+\-\(\)~@]/).filter((term) => !!term));
continue;
}
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index 2f728226c..596b1ae06 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -457,7 +457,7 @@ export function replaceHtmlEntities(text) {
};
var newtext = text;
for (var tag in tagsToReplace) {
- if ({}.hasOwnProperty.call(tagsToReplace, tag)) {
+ if (Reflect.apply({}.hasOwnProperty, this, [tagsToReplace, tag])) {
var regex = new RegExp(tag, 'g');
newtext = newtext.replace(regex, tagsToReplace[tag]);
}
@@ -473,7 +473,7 @@ export function insertHtmlEntities(text) {
};
var newtext = text;
for (var tag in tagsToReplace) {
- if ({}.hasOwnProperty.call(tagsToReplace, tag)) {
+ if (Reflect.apply({}.hasOwnProperty, this, [tagsToReplace, tag])) {
var regex = new RegExp(tag, 'g');
newtext = newtext.replace(regex, tagsToReplace[tag]);
}
@@ -734,7 +734,7 @@ export function applyTheme(theme) {
changeCss('.app__body .scrollbar--horizontal, .app__body .scrollbar--vertical', 'background:' + changeOpacity(theme.centerChannelColor, 0.5), 2);
changeCss('.app__body .post-list__new-messages-below', 'background:' + changeColor(theme.centerChannelColor, 0.5), 2);
changeCss('.app__body .post.post--comment .post__body', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.2), 1);
- changeCss('.app__body .post.post--comment.current--user .post__body', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.13), 1);
+ changeCss('.app__body .post.post--comment.current--user .post__body', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.2), 1);
}
if (theme.newMessageSeparator) {
@@ -924,7 +924,7 @@ export function isValidUsername(name) {
error = 'This field is required';
} else if (name.length < Constants.MIN_USERNAME_LENGTH || name.length > Constants.MAX_USERNAME_LENGTH) {
error = 'Must be between ' + Constants.MIN_USERNAME_LENGTH + ' and ' + Constants.MAX_USERNAME_LENGTH + ' characters';
- } else if (!(/^[a-z0-9\.\-\_]+$/).test(name)) {
+ } else if (!(/^[a-z0-9\.\-_]+$/).test(name)) {
error = "Must contain only letters, numbers, and the symbols '.', '-', and '_'.";
} else if (!(/[a-z]/).test(name.charAt(0))) { //eslint-disable-line no-negated-condition
error = 'First character must be a letter.';
@@ -977,7 +977,7 @@ Image.prototype.load = function imageLoad(url, progressCallback) {
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function onLoad() {
var h = xmlHTTP.getAllResponseHeaders();
- var m = h.match(/^Content-Type\:\s*(.*?)$/mi);
+ var m = h.match(/^Content-Type:\s*(.*?)$/mi);
var mimeType = m[1] || 'image/png';
var blob = new Blob([this.response], {type: mimeType});
@@ -1142,7 +1142,7 @@ export function generateId() {
// implementation taken from http://stackoverflow.com/a/2117523
var id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
- id = id.replace(/[xy]/g, function replaceRandom(c) {
+ id = id.replace(/[xy]/g, (c) => {
var r = Math.floor(Math.random() * 16);
var v;
diff --git a/webapp/utils/web_client.jsx b/webapp/utils/web_client.jsx
index 642e523b7..c7e4bd306 100644
--- a/webapp/utils/web_client.jsx
+++ b/webapp/utils/web_client.jsx
@@ -53,7 +53,7 @@ class WebClientClass extends Client {
}
},
(err) => {
- this.track('api', 'api_users_login_fail', name, 'login_id', loginId);
+ this.track('api', 'api_users_login_fail', '', 'login_id', loginId);
if (error) {
error(err);
}
@@ -75,7 +75,7 @@ class WebClientClass extends Client {
}
},
(err) => {
- this.track('api', 'api_users_login_fail', name, 'login_id', loginId);
+ this.track('api', 'api_users_login_fail', '', 'login_id', loginId);
if (error) {
error(err);
}