From fb5b57836ece6da2d0136802ca0d08346638b9e2 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 3 Nov 2015 14:52:25 -0500 Subject: Multiple fixes to major performance issues with teams with 50+ users --- web/react/utils/async_client.jsx | 16 ++++++++++++---- web/react/utils/client.jsx | 5 +++-- web/react/utils/constants.jsx | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index 75dd35e3f..0ecd26186 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -588,13 +588,21 @@ 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); + 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 +614,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, -- cgit v1.2.3-1-g7c22 From a26145ef91197ba374d525c947984ae672cbd94d Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 3 Nov 2015 15:11:16 -0500 Subject: Minor changes to statuses client code --- web/react/utils/async_client.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index 0ecd26186..205c7461c 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -593,7 +593,9 @@ export function getStatuses() { const teammateIds = []; for (var i = 0; i < directChannels.length; i++) { const teammate = utils.getDirectTeammate(directChannels[i].id); - teammateIds.push(teammate.id); + if (teammate) { + teammateIds.push(teammate.id); + } } if (isCallInProgress('getStatuses') || teammateIds.length === 0) { -- cgit v1.2.3-1-g7c22