From b79b2b2a53935cd883312c1158918291a926bacd Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 22 Dec 2016 15:20:36 -0300 Subject: Fix team switch (#4851) * Fix team switch * Fix channel switching by using BrowserStore * Fixes plt-5076 and plt-5068 * Updating styles for Teams sidebar (#4875) --- webapp/routes/route_team.jsx | 55 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'webapp/routes') diff --git a/webapp/routes/route_team.jsx b/webapp/routes/route_team.jsx index a71ed3149..8416b91c0 100644 --- a/webapp/routes/route_team.jsx +++ b/webapp/routes/route_team.jsx @@ -14,7 +14,7 @@ const ActionTypes = Constants.ActionTypes; import * as AsyncClient from 'utils/async_client.jsx'; import Client from 'client/web_client.jsx'; import ChannelStore from 'stores/channel_store.jsx'; -import PreferenceStore from 'stores/preference_store.jsx'; +import BrowserStore from 'stores/browser_store.jsx'; import emojiRoute from 'routes/route_emoji.jsx'; import integrationsRoute from 'routes/route_integrations.jsx'; @@ -70,45 +70,46 @@ function preNeedsTeam(nextState, replace, callback) { browserHistory.push('/'); return; } - if (nextState.location.pathname.indexOf('/channels/') > -1) { - GlobalActions.emitCloseRightHandSide(); - TeamStore.saveMyTeam(team); - TeamStore.emitChange(); + TeamStore.saveMyTeam(team); + BrowserStore.setGlobalItem('team', team.id); + TeamStore.emitChange(); + GlobalActions.emitCloseRightHandSide(); + + if (nextState.location.pathname.indexOf('/channels/') > -1 || + nextState.location.pathname.indexOf('/pl/') > -1) { loadProfilesAndTeamMembersForDMSidebar(); AsyncClient.getMyTeamsUnread(); AsyncClient.getMyChannelMembers(); + } - const d1 = $.Deferred(); //eslint-disable-line new-cap + const d1 = $.Deferred(); //eslint-disable-line new-cap - Client.getChannels( - (data) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNELS, - channels: data - }); + Client.getChannels( + (data) => { + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_CHANNELS, + channels: data + }); - loadStatusesForChannelAndSidebar(); + loadStatusesForChannelAndSidebar(); - d1.resolve(); - }, - (err) => { - AsyncClient.dispatchError(err, 'getChannels'); - d1.resolve(); - } - ); - - $.when(d1).done(() => { - callback(); - }); - } else { + d1.resolve(); + }, + (err) => { + AsyncClient.dispatchError(err, 'getChannels'); + d1.resolve(); + } + ); + + $.when(d1).done(() => { callback(); - } + }); } function selectLastChannel(nextState, replace, callback) { const team = TeamStore.getByName(nextState.params.team); - const channelId = PreferenceStore.get(team.id, 'channel'); + const channelId = BrowserStore.getGlobalItem(team.id); const channel = ChannelStore.getChannelById(channelId); let channelName = 'town-square'; -- cgit v1.2.3-1-g7c22