Merge branch 'master' of https://github.com/mattermost/platform into ui-improvements
Этот коммит содержится в:
@@ -3,6 +3,7 @@
|
||||
|
||||
var client = require('./client.jsx');
|
||||
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
||||
var BrowserStore = require('../stores/browser_store.jsx');
|
||||
var ChannelStore = require('../stores/channel_store.jsx');
|
||||
var PostStore = require('../stores/post_store.jsx');
|
||||
var UserStore = require('../stores/user_store.jsx');
|
||||
@@ -50,18 +51,18 @@ export function getChannels(force, updateLastViewed, checkVersion) {
|
||||
callTracker.getChannels = utils.getTimestamp();
|
||||
|
||||
client.getChannels(
|
||||
function getChannelsSuccess(data, textStatus, xhr) {
|
||||
(data, textStatus, xhr) => {
|
||||
callTracker.getChannels = 0;
|
||||
|
||||
if (checkVersion) {
|
||||
var serverVersion = xhr.getResponseHeader('X-Version-ID');
|
||||
|
||||
if (!UserStore.getLastVersion()) {
|
||||
UserStore.setLastVersion(serverVersion);
|
||||
if (!BrowserStore.getLastServerVersion()) {
|
||||
BrowserStore.setLastServerVersion(serverVersion);
|
||||
}
|
||||
|
||||
if (serverVersion !== UserStore.getLastVersion()) {
|
||||
UserStore.setLastVersion(serverVersion);
|
||||
if (serverVersion !== BrowserStore.getLastServerVersion()) {
|
||||
BrowserStore.setLastServerVersion(serverVersion);
|
||||
window.location.href = window.location.href;
|
||||
console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
|
||||
}
|
||||
@@ -77,7 +78,7 @@ export function getChannels(force, updateLastViewed, checkVersion) {
|
||||
members: data.members
|
||||
});
|
||||
},
|
||||
function getChannelsFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getChannels = 0;
|
||||
dispatchError(err, 'getChannels');
|
||||
}
|
||||
@@ -566,8 +567,8 @@ export function getMe() {
|
||||
}
|
||||
|
||||
callTracker.getMe = utils.getTimestamp();
|
||||
client.getMeSynchronous(
|
||||
function getMeSyncSuccess(data, textStatus, xhr) {
|
||||
client.getMe(
|
||||
(data, textStatus, xhr) => {
|
||||
callTracker.getMe = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
@@ -579,7 +580,7 @@ export function getMe() {
|
||||
me: data
|
||||
});
|
||||
},
|
||||
function getMeSyncFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getMe = 0;
|
||||
dispatchError(err, 'getMe');
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ var BrowserStore = require('../stores/browser_store.jsx');
|
||||
var TeamStore = require('../stores/team_store.jsx');
|
||||
var ErrorStore = require('../stores/error_store.jsx');
|
||||
|
||||
export function track(category, action, label, prop, val) {
|
||||
global.window.analytics.track(action, {category: category, label: label, property: prop, value: val});
|
||||
export function track(category, action, label, property, value) {
|
||||
global.window.analytics.track(action, {category, label, property, value});
|
||||
}
|
||||
|
||||
export function trackPage() {
|
||||
@@ -232,6 +232,7 @@ export function logout() {
|
||||
track('api', 'api_users_logout');
|
||||
var currentTeamUrl = TeamStore.getCurrentTeamUrl();
|
||||
BrowserStore.clear();
|
||||
ErrorStore.storeLastError(null);
|
||||
window.location.href = currentTeamUrl + '/logout';
|
||||
}
|
||||
|
||||
@@ -385,10 +386,9 @@ export function getAllTeams(success, error) {
|
||||
});
|
||||
}
|
||||
|
||||
export function getMeSynchronous(success, error) {
|
||||
export function getMe(success, error) {
|
||||
var currentUser = null;
|
||||
$.ajax({
|
||||
async: false,
|
||||
cache: false,
|
||||
url: '/api/v1/users/me',
|
||||
dataType: 'json',
|
||||
@@ -402,7 +402,7 @@ export function getMeSynchronous(success, error) {
|
||||
},
|
||||
error: function onError(xhr, status, err) {
|
||||
if (error) {
|
||||
var e = handleError('getMeSynchronous', xhr, status, err);
|
||||
var e = handleError('getMe', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ module.exports = {
|
||||
|
||||
RECIEVED_MSG: null,
|
||||
|
||||
CLICK_TEAM: null,
|
||||
RECIEVED_TEAM: null,
|
||||
|
||||
RECIEVED_CONFIG: null,
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
// See License.txt for license information.
|
||||
|
||||
const emoticonPatterns = {
|
||||
smile: /(^|\s)(:-?\))($|\s)/g, // :)
|
||||
wink: /(^|\s)(;-?\))($|\s)/g, // ;)
|
||||
open_mouth: /(^|\s)(:o)($|\s)/gi, // :o
|
||||
scream: /(^|\s)(:-o)($|\s)/gi, // :-o
|
||||
smirk: /(^|\s)(:-?])($|\s)/g, // :]
|
||||
grinning: /(^|\s)(:-?d)($|\s)/gi, // :D
|
||||
stuck_out_tongue_closed_eyes: /(^|\s)(x-d)($|\s)/gi, // x-d
|
||||
stuck_out_tongue: /(^|\s)(:-?p)($|\s)/gi, // :p
|
||||
rage: /(^|\s)(:-?[\[@])($|\s)/g, // :@
|
||||
frowning: /(^|\s)(:-?\()($|\s)/g, // :(
|
||||
sob: /(^|\s)(:['’]-?\(|:'\(|:'\()($|\s)/g, // :`(
|
||||
kissing_heart: /(^|\s)(:-?\*)($|\s)/g, // :*
|
||||
pensive: /(^|\s)(:-?\/)($|\s)/g, // :/
|
||||
confounded: /(^|\s)(:-?s)($|\s)/gi, // :s
|
||||
flushed: /(^|\s)(:-?\|)($|\s)/g, // :|
|
||||
relaxed: /(^|\s)(:-?\$)($|\s)/g, // :$
|
||||
mask: /(^|\s)(:-x)($|\s)/gi, // :-x
|
||||
heart: /(^|\s)(<3|<3)($|\s)/g, // <3
|
||||
broken_heart: /(^|\s)(<\/3|</3)($|\s)/g, // </3
|
||||
thumbsup: /(^|\s)(:\+1:)($|\s)/g, // :+1:
|
||||
thumbsdown: /(^|\s)(:\-1:)($|\s)/g // :-1:
|
||||
smile: /(^|\s)(:-?\))(?=$|\s)/g, // :)
|
||||
wink: /(^|\s)(;-?\))(?=$|\s)/g, // ;)
|
||||
open_mouth: /(^|\s)(:o)(?=$|\s)/gi, // :o
|
||||
scream: /(^|\s)(:-o)(?=$|\s)/gi, // :-o
|
||||
smirk: /(^|\s)(:-?])(?=$|\s)/g, // :]
|
||||
grinning: /(^|\s)(:-?d)(?=$|\s)/gi, // :D
|
||||
stuck_out_tongue_closed_eyes: /(^|\s)(x-d)(?=$|\s)/gi, // x-d
|
||||
stuck_out_tongue: /(^|\s)(:-?p)(?=$|\s)/gi, // :p
|
||||
rage: /(^|\s)(:-?[\[@])(?=$|\s)/g, // :@
|
||||
frowning: /(^|\s)(:-?\()(?=$|\s)/g, // :(
|
||||
sob: /(^|\s)(:['’]-?\(|:'\(|:'\()(?=$|\s)/g, // :`(
|
||||
kissing_heart: /(^|\s)(:-?\*)(?=$|\s)/g, // :*
|
||||
pensive: /(^|\s)(:-?\/)(?=$|\s)/g, // :/
|
||||
confounded: /(^|\s)(:-?s)(?=$|\s)/gi, // :s
|
||||
flushed: /(^|\s)(:-?\|)(?=$|\s)/g, // :|
|
||||
relaxed: /(^|\s)(:-?\$)(?=$|\s)/g, // :$
|
||||
mask: /(^|\s)(:-x)(?=$|\s)/gi, // :-x
|
||||
heart: /(^|\s)(<3|<3)(?=$|\s)/g, // <3
|
||||
broken_heart: /(^|\s)(<\/3|</3)(?=$|\s)/g, // </3
|
||||
thumbsup: /(^|\s)(:\+1:)(?=$|\s)/g, // :+1:
|
||||
thumbsdown: /(^|\s)(:\-1:)(?=$|\s)/g // :-1:
|
||||
};
|
||||
|
||||
function initializeEmoticonMap() {
|
||||
@@ -127,28 +127,28 @@ const emoticonMap = initializeEmoticonMap();
|
||||
export function handleEmoticons(text, tokens) {
|
||||
let output = text;
|
||||
|
||||
function replaceEmoticonWithToken(match, prefix, name, suffix) {
|
||||
function replaceEmoticonWithToken(fullMatch, prefix, matchText, name) {
|
||||
if (emoticonMap[name]) {
|
||||
const index = tokens.size;
|
||||
const alias = `MM_EMOTICON${index}`;
|
||||
|
||||
tokens.set(alias, {
|
||||
value: `<img align="absmiddle" alt="${match}" class="emoji" src="${getImagePathForEmoticon(name)}" title="${match}" />`,
|
||||
originalText: match
|
||||
value: `<img align="absmiddle" alt="${matchText}" class="emoji" src="${getImagePathForEmoticon(name)}" title="${matchText}" />`,
|
||||
originalText: fullMatch
|
||||
});
|
||||
|
||||
return prefix + alias + suffix;
|
||||
return prefix + alias;
|
||||
}
|
||||
|
||||
return match;
|
||||
return fullMatch;
|
||||
}
|
||||
|
||||
output = output.replace(/(^|\s):([a-zA-Z0-9_-]+):($|\s)/g, replaceEmoticonWithToken);
|
||||
output = output.replace(/(^|\s)(:([a-zA-Z0-9_-]+):)(?=$|\s)/g, (fullMatch, prefix, matchText, name) => replaceEmoticonWithToken(fullMatch, prefix, matchText, 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, (match, prefix, emoticon, suffix) => replaceEmoticonWithToken(match, prefix, name, suffix));
|
||||
output = output.replace(pattern, (fullMatch, prefix, matchText) => replaceEmoticonWithToken(fullMatch, prefix, matchText, name));
|
||||
});
|
||||
|
||||
return output;
|
||||
|
||||
@@ -869,7 +869,7 @@ export function getFileUrl(filename) {
|
||||
if (url.indexOf('/api/v1/files/get') !== -1) {
|
||||
url = filename.split('/api/v1/files/get')[1];
|
||||
}
|
||||
url = getWindowLocationOrigin() + '/api/v1/files/get' + url;
|
||||
url = getWindowLocationOrigin() + '/api/v1/files/get' + url + '?' + getSessionIndex();
|
||||
|
||||
return url;
|
||||
}
|
||||
@@ -880,6 +880,14 @@ export function getFileName(path) {
|
||||
return split[split.length - 1];
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Ссылка в новой задаче
Block a user