From 7883a515e72690e08e10d38fafc741da1e7a0deb Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 23 Feb 2017 02:33:13 +0000 Subject: [PATCH] Fix Utils importing in ChannelStore. (#5503) This fixes a whole load of bugs around Channel Members Modals, and elsewhere where the Channel Members are used. Most of those bugs have been alreay closed as "Cannot Reproduce" becaues the issue was a really nasty race condition in the javascript! --- webapp/stores/channel_store.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx index 0228345bc3..c46e170167 100644 --- a/webapp/stores/channel_store.jsx +++ b/webapp/stores/channel_store.jsx @@ -7,6 +7,7 @@ import EventEmitter from 'events'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; +var ChannelUtils; var Utils; import {ActionTypes, Constants} from 'utils/constants.jsx'; import {isSystemMessage} from 'utils/post_utils.jsx'; @@ -204,11 +205,11 @@ class ChannelStoreClass extends EventEmitter { channels.push(channel); } - if (!Utils) { - Utils = require('utils/channel_utils.jsx'); //eslint-disable-line global-require + if (!ChannelUtils) { + ChannelUtils = require('utils/channel_utils.jsx'); //eslint-disable-line global-require } - channels = channels.sort(Utils.sortChannelsByDisplayName); + channels = channels.sort(ChannelUtils.sortChannelsByDisplayName); this.storeChannels(channels); } @@ -286,11 +287,11 @@ class ChannelStoreClass extends EventEmitter { getMoreChannelsList(teamId = TeamStore.getCurrentId()) { const teamChannels = this.moreChannels[teamId] || {}; - if (!Utils) { - Utils = require('utils/channel_utils.jsx'); //eslint-disable-line global-require + if (!ChannelUtils) { + ChannelUtils = require('utils/channel_utils.jsx'); //eslint-disable-line global-require } - return Object.keys(teamChannels).map((cid) => teamChannels[cid]).sort(Utils.sortChannelsByDisplayName); + return Object.keys(teamChannels).map((cid) => teamChannels[cid]).sort(ChannelUtils.sortChannelsByDisplayName); } storeStats(stats) {