summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx18
-rw-r--r--web/react/utils/client.jsx5
-rw-r--r--web/react/utils/constants.jsx1
-rw-r--r--web/react/utils/markdown.jsx3
-rw-r--r--web/react/utils/utils.jsx21
5 files changed, 41 insertions, 7 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 75dd35e3f..205c7461c 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -588,13 +588,23 @@ export function getMe() {
}
export function getStatuses() {
- if (isCallInProgress('getStatuses')) {
+ const directChannels = ChannelStore.getAll().filter((channel) => channel.type === Constants.DM_CHANNEL);
+
+ const teammateIds = [];
+ for (var i = 0; i < directChannels.length; i++) {
+ const teammate = utils.getDirectTeammate(directChannels[i].id);
+ if (teammate) {
+ teammateIds.push(teammate.id);
+ }
+ }
+
+ if (isCallInProgress('getStatuses') || teammateIds.length === 0) {
return;
}
callTracker.getStatuses = utils.getTimestamp();
- client.getStatuses(
- function getStatusesSuccess(data, textStatus, xhr) {
+ client.getStatuses(teammateIds,
+ (data, textStatus, xhr) => {
callTracker.getStatuses = 0;
if (xhr.status === 304 || !data) {
@@ -606,7 +616,7 @@ export function getStatuses() {
statuses: data
});
},
- function getStatusesFailure(err) {
+ (err) => {
callTracker.getStatuses = 0;
dispatchError(err, 'getStatuses');
}
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 7ce1346f9..003e24d33 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -1069,12 +1069,13 @@ export function exportTeam(success, error) {
});
}
-export function getStatuses(success, error) {
+export function getStatuses(ids, success, error) {
$.ajax({
url: '/api/v1/users/status',
dataType: 'json',
contentType: 'application/json',
- type: 'GET',
+ type: 'POST',
+ data: JSON.stringify(ids),
success,
error: function onError(xhr, status, err) {
var e = handleError('getStatuses', xhr, status, err);
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index fd64b1554..39be577df 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -127,6 +127,7 @@ module.exports = {
MAX_DMS: 20,
DM_CHANNEL: 'D',
OPEN_CHANNEL: 'O',
+ PRIVATE_CHANNEL: 'P',
INVITE_TEAM: 'I',
OPEN_TEAM: 'O',
MAX_POST_LEN: 4000,
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index f9416b2de..3ef09211f 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -208,7 +208,8 @@ export function format(text, options) {
const markdownOptions = {
renderer: new MattermostMarkdownRenderer(null, options),
sanitize: true,
- gfm: true
+ gfm: true,
+ tables: true
};
const tokens = marked.lexer(text, markdownOptions);
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index c82bd1065..e8d34dccd 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -1104,3 +1104,24 @@ export function openDirectChannelToUser(user, successCb, errorCb) {
);
}
}
+
+// Use when sorting multiple channels or teams by their `display_name` field
+export function sortByDisplayName(a, b) {
+ let aDisplayName = '';
+ let bDisplayName = '';
+
+ if (a && a.display_name) {
+ aDisplayName = a.display_name.toLowerCase();
+ }
+ if (b && b.display_name) {
+ bDisplayName = b.display_name.toLowerCase();
+ }
+
+ if (aDisplayName < bDisplayName) {
+ return -1;
+ }
+ if (aDisplayName > bDisplayName) {
+ return 1;
+ }
+ return 0;
+}