summaryrefslogtreecommitdiffstats
path: root/webapp/actions/global_actions.jsx
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-12-22 15:20:36 -0300
committerCorey Hulen <corey@hulen.com>2016-12-22 10:20:36 -0800
commitb79b2b2a53935cd883312c1158918291a926bacd (patch)
treefeb178ef53b3f8edf47824556bd4ba57ded8ce8d /webapp/actions/global_actions.jsx
parentc9eb23a3d44c96042522bf7cdefc65903eb1d0a3 (diff)
downloadchat-b79b2b2a53935cd883312c1158918291a926bacd.tar.gz
chat-b79b2b2a53935cd883312c1158918291a926bacd.tar.bz2
chat-b79b2b2a53935cd883312c1158918291a926bacd.zip
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)
Diffstat (limited to 'webapp/actions/global_actions.jsx')
-rw-r--r--webapp/actions/global_actions.jsx30
1 files changed, 24 insertions, 6 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index e1009e9c2..d3fc2cd29 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -53,6 +53,8 @@ export function emitChannelClickEvent(channel) {
trackPage();
});
+ BrowserStore.setGlobalItem(chan.team_id, chan.id);
+
AppDispatcher.handleViewAction({
type: ActionTypes.CLICK_CHANNEL,
name: chan.name,
@@ -542,7 +544,11 @@ export function emitBrowserFocus(focus) {
export function redirectUserToDefaultTeam() {
const teams = TeamStore.getAll();
const teamMembers = TeamStore.getMyTeamMembers();
- let teamId = PreferenceStore.get('last', 'team');
+ let teamId = BrowserStore.getGlobalItem('team');
+
+ function redirect(teamName, channelName) {
+ browserHistory.push(`/${teamName}/channels/${channelName}`);
+ }
if (!teams[teamId] && teamMembers.length > 0) {
let myTeams = [];
@@ -560,12 +566,24 @@ export function redirectUserToDefaultTeam() {
}
if (teams[teamId]) {
- const channelId = PreferenceStore.get(teamId, 'channel');
- let channel = ChannelStore.getChannelById(channelId);
- if (!channel) {
- channel = 'town-square';
+ const channelId = BrowserStore.getGlobalItem(teamId);
+ const channel = ChannelStore.getChannelById(channelId);
+ if (channel) {
+ redirect(teams[teamId].name, channel);
+ } else if (channelId) {
+ Client.setTeamId(teamId);
+ Client.getChannel(
+ channelId,
+ (data) => {
+ redirect(teams[teamId].name, data.channel.name);
+ },
+ () => {
+ redirect(teams[teamId].name, 'town-square');
+ }
+ );
+ } else {
+ redirect(teams[teamId].name, 'town-square');
}
- browserHistory.push(`/${teams[teamId].name}/channels/${channel}`);
} else {
browserHistory.push('/select_team');
}