summaryrefslogtreecommitdiffstats
path: root/webapp/routes
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-04-28 13:16:03 -0400
committerChristopher Speller <crspeller@gmail.com>2017-04-28 13:16:03 -0400
commit96906482cecb0df21c8e1a40a2ba00c13c0182a7 (patch)
tree3bb35ca9fe2a3beb212b5350116f7bb488d7a119 /webapp/routes
parent302ec17beed9128101ef61d69b45d3ee29e16f1e (diff)
downloadchat-96906482cecb0df21c8e1a40a2ba00c13c0182a7.tar.gz
chat-96906482cecb0df21c8e1a40a2ba00c13c0182a7.tar.bz2
chat-96906482cecb0df21c8e1a40a2ba00c13c0182a7.zip
PLT-6214 Move channel store and actions over to redux (#6235)
* Move channel store and actions over to redux * Fix style errors * Fix unit test * Various fixes * More fixes * Revert config changes
Diffstat (limited to 'webapp/routes')
-rw-r--r--webapp/routes/route_team.jsx52
1 files changed, 21 insertions, 31 deletions
diff --git a/webapp/routes/route_team.jsx b/webapp/routes/route_team.jsx
index 0a3c0a59f..45494dca5 100644
--- a/webapp/routes/route_team.jsx
+++ b/webapp/routes/route_team.jsx
@@ -6,14 +6,12 @@ import * as RouteUtils from 'routes/route_utils.jsx';
import {browserHistory} from 'react-router/es6';
import TeamStore from 'stores/team_store.jsx';
+import UserStore from 'stores/user_store.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {loadStatusesForChannelAndSidebar} from 'actions/status_actions.jsx';
import {reconnect} from 'actions/websocket_actions.jsx';
-import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import Constants from 'utils/constants.jsx';
-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 BrowserStore from 'stores/browser_store.jsx';
@@ -22,6 +20,13 @@ import integrationsRoute from 'routes/route_integrations.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions.jsx';
+// Redux actions
+import store from 'stores/redux_store.jsx';
+const dispatch = store.dispatch;
+const getState = store.getState;
+
+import {fetchMyChannelsAndMembers, joinChannel} from 'mattermost-redux/actions/channels';
+
function onChannelEnter(nextState, replace, callback) {
doChannelChange(nextState, replace, callback);
}
@@ -40,22 +45,16 @@ function doChannelChange(state, replace, callback) {
}
if (!channel) {
- Client.joinChannelByName(
- state.params.channel,
+ joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, state.params.channel)(dispatch, getState).then(
(data) => {
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_CHANNEL,
- channel: data
- });
-
- GlobalActions.emitChannelClickEvent(data);
- callback();
- },
- () => {
- if (state.params.team) {
- replace('/' + state.params.team + '/channels/town-square');
- } else {
- replace('/');
+ if (data) {
+ GlobalActions.emitChannelClickEvent(data.channel);
+ } else if (data == null) {
+ if (state.params.team) {
+ replace('/' + state.params.team + '/channels/town-square');
+ } else {
+ replace('/');
+ }
}
callback();
}
@@ -107,26 +106,17 @@ function preNeedsTeam(nextState, replace, callback) {
if (nextState.location.pathname.indexOf('/channels/') > -1 ||
nextState.location.pathname.indexOf('/pl/') > -1) {
AsyncClient.getMyTeamsUnread();
- AsyncClient.getMyChannelMembersForTeam(team.id);
+ fetchMyChannelsAndMembers(team.id)(dispatch, getState);
}
const d1 = $.Deferred(); //eslint-disable-line new-cap
- Client.getChannels(
- (data) => {
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_CHANNELS,
- channels: data
- });
-
+ fetchMyChannelsAndMembers(team.id)(dispatch, getState).then(
+ () => {
loadStatusesForChannelAndSidebar();
loadProfilesForSidebar();
d1.resolve();
- },
- (err) => {
- AsyncClient.dispatchError(err, 'getChannels');
- d1.resolve();
}
);
@@ -166,7 +156,7 @@ export default {
emojiRoute,
{
getComponents: (location, callback) => {
- System.import('components/needs_team.jsx').then(RouteUtils.importComponentSuccess(callback));
+ System.import('components/needs_team').then(RouteUtils.importComponentSuccess(callback));
},
childRoutes: [
{