From 7f48a7fc9d2238134414668e0b520115706b8b2d Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Thu, 15 Dec 2016 11:40:46 -0500
Subject: PLT-4815 Refactor 'More Channels' modal into the new modal pattern
 (#4742)

* Refactor 'More Channels' modal into the new modal pattern

* Fix unit test

* Readded CSS changes
---
 webapp/stores/channel_store.jsx | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

(limited to 'webapp/stores/channel_store.jsx')

diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx
index 0e2c43a60..af7238267 100644
--- a/webapp/stores/channel_store.jsx
+++ b/webapp/stores/channel_store.jsx
@@ -4,6 +4,8 @@
 import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
 import EventEmitter from 'events';
 
+import TeamStore from 'stores/team_store.jsx';
+
 var Utils;
 import {ActionTypes, Constants} from 'utils/constants.jsx';
 const NotificationPrefs = Constants.NotificationPrefs;
@@ -233,24 +235,25 @@ class ChannelStoreClass extends EventEmitter {
         return this.myChannelMembers;
     }
 
-    storeMoreChannels(channels) {
+    storeMoreChannels(channels, teamId = TeamStore.getCurrentId()) {
         const newChannels = {};
         for (let i = 0; i < channels.length; i++) {
             newChannels[channels[i].id] = channels[i];
         }
-        this.moreChannels = Object.assign({}, this.moreChannels, newChannels);
+        this.moreChannels[teamId] = Object.assign({}, this.moreChannels[teamId], newChannels);
     }
 
-    removeMoreChannel(channelId) {
-        Reflect.deleteProperty(this.moreChannels, channelId);
+    removeMoreChannel(channelId, teamId = TeamStore.getCurrentId()) {
+        Reflect.deleteProperty(this.moreChannels[teamId], channelId);
     }
 
-    getMoreChannels() {
-        return Object.assign({}, this.moreChannels);
+    getMoreChannels(teamId = TeamStore.getCurrentId()) {
+        return Object.assign({}, this.moreChannels[teamId]);
     }
 
-    getMoreChannelsList() {
-        return Object.keys(this.moreChannels).map((cid) => this.moreChannels[cid]);
+    getMoreChannelsList(teamId = TeamStore.getCurrentId()) {
+        const teamChannels = this.moreChannels[teamId] || {};
+        return Object.keys(teamChannels).map((cid) => teamChannels[cid]);
     }
 
     storeStats(stats) {
-- 
cgit v1.2.3-1-g7c22

