summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/global_actions.jsx30
-rw-r--r--webapp/actions/websocket_actions.jsx7
2 files changed, 25 insertions, 12 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');
}
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 0b2c2102e..63f2c535a 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -6,7 +6,6 @@ import $ from 'jquery';
import UserStore from 'stores/user_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import PostStore from 'stores/post_store.jsx';
-import PreferenceStore from 'stores/preference_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
@@ -224,11 +223,7 @@ function handleLeaveTeamEvent(msg) {
if (TeamStore.getCurrentId() === msg.data.team_id) {
TeamStore.setCurrentId('');
Client.setTeamId('');
- PreferenceStore.deletePreference({
- category: 'last',
- name: 'team',
- value: msg.data.team_id
- });
+ BrowserStore.removeGlobalItem(msg.data.team_id);
GlobalActions.redirectUserToDefaultTeam();
}
} else {