summaryrefslogtreecommitdiffstats
path: root/webapp/routes
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/routes')
-rw-r--r--webapp/routes/route_team.jsx31
1 files changed, 25 insertions, 6 deletions
diff --git a/webapp/routes/route_team.jsx b/webapp/routes/route_team.jsx
index 88fab8d45..10bbcc4df 100644
--- a/webapp/routes/route_team.jsx
+++ b/webapp/routes/route_team.jsx
@@ -14,6 +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 emojiRoute from 'routes/route_emoji.jsx';
import integrationsRoute from 'routes/route_integrations.jsx';
@@ -63,7 +64,7 @@ function preNeedsTeam(nextState, replace, callback) {
// First check to make sure you're in the current team
// for the current url.
const teamName = nextState.params.team;
- var team = TeamStore.getByName(teamName);
+ const team = TeamStore.getByName(teamName);
if (!team) {
browserHistory.push('/');
@@ -75,9 +76,10 @@ function preNeedsTeam(nextState, replace, callback) {
TeamStore.saveMyTeam(team);
TeamStore.emitChange();
loadProfilesAndTeamMembersForDMSidebar();
+ AsyncClient.getMyTeamsUnread();
AsyncClient.getMyChannelMembers();
- var d1 = $.Deferred(); //eslint-disable-line new-cap
+ const d1 = $.Deferred(); //eslint-disable-line new-cap
Client.getChannels(
(data) => {
@@ -101,6 +103,20 @@ function preNeedsTeam(nextState, replace, callback) {
});
}
+function selectLastChannel(nextState, replace, callback) {
+ const team = TeamStore.getByName(nextState.params.team);
+ const channelId = PreferenceStore.get(team.id, 'channel');
+ const channel = ChannelStore.getChannelById(channelId);
+
+ let channelName = 'town-square';
+ if (channel) {
+ channelName = channel.name;
+ }
+
+ replace(`/${team.name}/channels/${channelName}`);
+ callback();
+}
+
function onPermalinkEnter(nextState, replace, callback) {
const postId = nextState.params.postid;
GlobalActions.emitPostFocusEvent(
@@ -112,7 +128,7 @@ function onPermalinkEnter(nextState, replace, callback) {
export default {
path: ':team',
onEnter: preNeedsTeam,
- indexRoute: {onEnter: (nextState, replace) => replace('/' + nextState.params.team + '/channels/town-square')},
+ indexRoute: {onEnter: selectLastChannel},
childRoutes: [
integrationsRoute,
emojiRoute,
@@ -126,10 +142,11 @@ export default {
onEnter: onChannelEnter,
getComponents: (location, callback) => {
Promise.all([
+ System.import('components/team_sidebar/team_sidebar_controller.jsx'),
System.import('components/sidebar.jsx'),
System.import('components/channel_view.jsx')
]).then(
- (comarr) => callback(null, {sidebar: comarr[0].default, center: comarr[1].default})
+ (comarr) => callback(null, {team_sidebar: comarr[0].default, sidebar: comarr[1].default, center: comarr[2].default})
);
}
},
@@ -138,10 +155,11 @@ export default {
onEnter: onPermalinkEnter,
getComponents: (location, callback) => {
Promise.all([
+ System.import('components/team_sidebar/team_sidebar_controller.jsx'),
System.import('components/sidebar.jsx'),
System.import('components/permalink_view.jsx')
]).then(
- (comarr) => callback(null, {sidebar: comarr[0].default, center: comarr[1].default})
+ (comarr) => callback(null, {team_sidebar: comarr[0].default, sidebar: comarr[1].default, center: comarr[2].default})
);
}
},
@@ -149,10 +167,11 @@ export default {
path: 'tutorial',
getComponents: (location, callback) => {
Promise.all([
+ System.import('components/team_sidebar/team_sidebar_controller.jsx'),
System.import('components/sidebar.jsx'),
System.import('components/tutorial/tutorial_view.jsx')
]).then(
- (comarr) => callback(null, {sidebar: comarr[0].default, center: comarr[1].default})
+ (comarr) => callback(null, {team_sidebar: comarr[0].default, sidebar: comarr[1].default, center: comarr[2].default})
);
}
}