summaryrefslogtreecommitdiffstats
path: root/webapp/action_creators/global_actions.jsx
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-03-29 08:08:25 -0700
committerCorey Hulen <corey@hulen.com>2016-03-29 08:08:25 -0700
commitd921c112de622c1919650bc919d32681112cf3a9 (patch)
tree9103b0d16fa676f15591f9704fa62f673aa23cac /webapp/action_creators/global_actions.jsx
parent4a6edbfd0854c097cf8fb64a3ddd75b43dfcd401 (diff)
parent5ce1a4368bafbd2ed50b1953658fca285cfd349b (diff)
downloadchat-d921c112de622c1919650bc919d32681112cf3a9.tar.gz
chat-d921c112de622c1919650bc919d32681112cf3a9.tar.bz2
chat-d921c112de622c1919650bc919d32681112cf3a9.zip
Merge pull request #2558 from mattermost/center-panel-refactor
PLT-2382, PLT-2386, PLT-2455 Channel/permalink view cleanup and fixes.
Diffstat (limited to 'webapp/action_creators/global_actions.jsx')
-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
});
}
+