summaryrefslogtreecommitdiffstats
path: root/webapp/routes
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-12-19 10:05:46 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-12-19 08:05:46 -0500
commit999d1553e1ce45adf58f6082b160bc1147dc592b (patch)
tree369a9b7f46dd44d136a79a050469429169433cec /webapp/routes
parent3ce2ce9dc882ed962dc3ce7550bdb07963f376b6 (diff)
downloadchat-999d1553e1ce45adf58f6082b160bc1147dc592b.tar.gz
chat-999d1553e1ce45adf58f6082b160bc1147dc592b.tar.bz2
chat-999d1553e1ce45adf58f6082b160bc1147dc592b.zip
PLT-4167 Team Sidebar (#4569)
* PLT-4167 Team Sidebar * Address feedback from PM * change route from my_members to members * bug fixes * Updating styles for teams sidebar (#4681) * Added PM changes * Fix corner cases * Addressing feedback * use two different endpoints * Bug fixes * Rename model and client functions, using preferences to store last team and channel viewed * Fix mobile notification count and closing the team sidebar * unit test, fixed bad merge and retrieve from cached when available * bug fixes * use id for last channel in preferences, query optimization * Updating multi team css (#4830)
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})
);
}
}