summaryrefslogtreecommitdiffstats
path: root/webapp/actions/websocket_actions.jsx
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/actions/websocket_actions.jsx
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/actions/websocket_actions.jsx')
-rw-r--r--webapp/actions/websocket_actions.jsx20
1 files changed, 14 insertions, 6 deletions
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 57f78f95f..c6de42647 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -30,6 +30,13 @@ import {ActionTypes, Constants, Preferences, SocketEvents, UserStatuses} from 'u
import {browserHistory} from 'react-router/es6';
+// Redux actions
+import store from 'stores/redux_store.jsx';
+const dispatch = store.dispatch;
+const getState = store.getState;
+import {viewChannel, getChannelAndMyMember, getChannelStats} from 'mattermost-redux/actions/channels';
+import {ChannelTypes} from 'mattermost-redux/action_types';
+
const MAX_WEBSOCKET_FAILS = 7;
export function initialize() {
@@ -241,7 +248,7 @@ function handlePostEditEvent(msg) {
// Update channel state
if (ChannelStore.getCurrentId() === msg.broadcast.channel_id) {
if (window.isActive) {
- AsyncClient.viewChannel();
+ viewChannel(ChannelStore.getCurrentId())(dispatch, getState);
}
}
}
@@ -297,18 +304,18 @@ function handleUpdateTeamEvent(msg) {
}
function handleDirectAddedEvent(msg) {
- AsyncClient.getChannel(msg.broadcast.channel_id);
+ getChannelAndMyMember(msg.broadcast.channel_id)(dispatch, getState);
PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, msg.data.teammate_id, 'true');
loadProfilesForSidebar();
}
function handleUserAddedEvent(msg) {
if (ChannelStore.getCurrentId() === msg.broadcast.channel_id) {
- AsyncClient.getChannelStats();
+ getChannelStats(ChannelStore.getCurrentId())(dispatch, getState);
}
if (TeamStore.getCurrentId() === msg.data.team_id && UserStore.getCurrentId() === msg.data.user_id) {
- AsyncClient.getChannel(msg.broadcast.channel_id);
+ getChannelAndMyMember(msg.broadcast.channel_id)(dispatch, getState);
}
}
@@ -327,7 +334,7 @@ function handleUserRemovedEvent(msg) {
$('#removed_from_channel').modal('show');
}
} else if (ChannelStore.getCurrentId() === msg.broadcast.channel_id) {
- AsyncClient.getChannelStats();
+ getChannelStats(ChannelStore.getCurrentId())(dispatch, getState);
}
}
@@ -343,7 +350,7 @@ function handleChannelCreatedEvent(msg) {
const teamId = msg.data.team_id;
if (TeamStore.getCurrentId() === teamId && !ChannelStore.getChannelById(channelId)) {
- AsyncClient.getChannel(channelId);
+ getChannelAndMyMember(channelId)(dispatch, getState);
}
}
@@ -352,6 +359,7 @@ function handleChannelDeletedEvent(msg) {
const teamUrl = TeamStore.getCurrentTeamRelativeUrl();
browserHistory.push(teamUrl + '/channels/' + Constants.DEFAULT_CHANNEL);
}
+ dispatch({type: ChannelTypes.RECEIVED_CHANNEL_DELETED, data: {id: msg.data.channel_id, team_id: msg.broadcast.team_id}}, getState);
loadChannelsForCurrentUser();
}