summaryrefslogtreecommitdiffstats
path: root/webapp/action_creators
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-24 20:04:40 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-29 09:54:55 -0400
commit5ce1a4368bafbd2ed50b1953658fca285cfd349b (patch)
tree9609d2ee90371ee0393a95f5fe67d27b5621257c /webapp/action_creators
parentbf636404d25e943d869a32d8fe145eaa57a64039 (diff)
downloadchat-5ce1a4368bafbd2ed50b1953658fca285cfd349b.tar.gz
chat-5ce1a4368bafbd2ed50b1953658fca285cfd349b.tar.bz2
chat-5ce1a4368bafbd2ed50b1953658fca285cfd349b.zip
Refactoring center panel away. Moving tutorial to a route. Fixing a
bunch of bugs.
Diffstat (limited to 'webapp/action_creators')
-rw-r--r--webapp/action_creators/global_actions.jsx56
1 files changed, 46 insertions, 10 deletions
diff --git a/webapp/action_creators/global_actions.jsx b/webapp/action_creators/global_actions.jsx
index 7322f1150..9c38d8955 100644
--- a/webapp/action_creators/global_actions.jsx
+++ b/webapp/action_creators/global_actions.jsx
@@ -13,23 +13,56 @@ import * as Utils from 'utils/utils.jsx';
import * as Websockets from './websocket_actions.jsx';
import * as I18n from 'i18n/i18n.jsx';
+import {browserHistory} from 'react-router';
+
import en from 'i18n/en.json';
export function emitChannelClickEvent(channel) {
- AsyncClient.getChannels(true);
- AsyncClient.getChannelExtraInfo(channel.id);
- AsyncClient.updateLastViewedAt(channel.id);
- AsyncClient.getPosts(channel.id);
+ function userVisitedFakeChannel(chan, success, fail) {
+ const otherUserId = Utils.getUserIdFromChannelName(chan);
+ Client.createDirectChannel(
+ chan,
+ otherUserId,
+ (data) => {
+ success(data);
+ },
+ () => {
+ fail();
+ }
+ );
+ }
+ function switchToChannel(chan) {
+ AsyncClient.getChannels(true);
+ AsyncClient.getChannelExtraInfo(chan.id);
+ AsyncClient.updateLastViewedAt(chan.id);
+ AsyncClient.getPosts(chan.id);
+ Client.trackPage();
+
+ AppDispatcher.handleViewAction({
+ type: ActionTypes.CLICK_CHANNEL,
+ name: chan.name,
+ id: chan.id,
+ prev: ChannelStore.getCurrentId()
+ });
+ }
- AppDispatcher.handleViewAction({
- type: ActionTypes.CLICK_CHANNEL,
- name: channel.name,
- id: channel.id,
- prev: ChannelStore.getCurrentId()
- });
+ if (channel.fake) {
+ userVisitedFakeChannel(
+ channel,
+ (data) => {
+ switchToChannel(data);
+ },
+ () => {
+ browserHistory.push('/' + this.state.currentTeam.name);
+ }
+ );
+ } else {
+ switchToChannel(channel);
+ }
}
export function emitPostFocusEvent(postId) {
+ AsyncClient.getChannels(true);
Client.getPostById(
postId,
(data) => {
@@ -39,6 +72,8 @@ export function emitPostFocusEvent(postId) {
post_list: data
});
+ AsyncClient.getChannelExtraInfo(data.channel_id);
+
AsyncClient.getPostsBefore(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS);
AsyncClient.getPostsAfter(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS);
}
@@ -300,3 +335,4 @@ export function emitRemoteUserTypingEvent(channelId, userId, postParentId) {
postParentId
});
}
+