summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
committerChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
commit323ce8b203c570ed6a1dd57b44d6637ad8207616 (patch)
treeefc3c61b905244bdb0e1ace0ce9f5ae4876644ad /webapp/actions
parentd1207d34c1d99eba9ebf85c98d267ee7e955ea7d (diff)
parentb55ec6148caa93d54b660afe55408c643d217108 (diff)
downloadchat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.gz
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.bz2
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.zip
Merge branch 'release-3.5'
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/global_actions.jsx24
-rw-r--r--webapp/actions/post_actions.jsx2
-rw-r--r--webapp/actions/websocket_actions.jsx49
3 files changed, 41 insertions, 34 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index 6a63b5630..f7c4c455c 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -43,16 +43,20 @@ export function emitChannelClickEvent(channel) {
);
}
function switchToChannel(chan) {
- AsyncClient.getChannelStats(chan.id, true);
- AsyncClient.updateLastViewedAt(chan.id);
- loadPosts(chan.id);
- trackPage();
-
- AppDispatcher.handleViewAction({
- type: ActionTypes.CLICK_CHANNEL,
- name: chan.name,
- id: chan.id,
- prev: ChannelStore.getCurrentId()
+ const getMyChannelMembersPromise = AsyncClient.getChannelMember(chan.id, UserStore.getCurrentId());
+
+ getMyChannelMembersPromise.then(() => {
+ AsyncClient.getChannelStats(chan.id, true);
+ AsyncClient.updateLastViewedAt(chan.id);
+ loadPosts(chan.id);
+ trackPage();
+
+ AppDispatcher.handleViewAction({
+ type: ActionTypes.CLICK_CHANNEL,
+ name: chan.name,
+ id: chan.id,
+ prev: ChannelStore.getCurrentId()
+ });
});
}
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index c2cc211b7..9599a9a77 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -232,7 +232,7 @@ export function loadPostsAfter(postId, offset, numPost, isPost) {
);
}
-function loadProfilesForPosts(posts) {
+export function loadProfilesForPosts(posts) {
const profilesToLoad = {};
for (const pid in posts) {
if (!posts.hasOwnProperty(pid)) {
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 431922b0d..36c6cbdc9 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -30,34 +30,37 @@ import {browserHistory} from 'react-router/es6';
const MAX_WEBSOCKET_FAILS = 7;
export function initialize() {
- if (window.WebSocket) {
- let connUrl = Utils.getSiteURL();
+ if (!window.WebSocket) {
+ console.log('Browser does not support websocket'); //eslint-disable-line no-console
+ return;
+ }
- // replace the protocol with a websocket one
- if (connUrl.startsWith('https:')) {
- connUrl = connUrl.replace(/^https:/, 'wss:');
- } else {
- connUrl = connUrl.replace(/^http:/, 'ws:');
- }
+ let connUrl = Utils.getSiteURL();
- // append a port number if one isn't already specified
- if (!(/:\d+$/).test(connUrl)) {
- if (connUrl.startsWith('wss:')) {
- connUrl += ':' + global.window.mm_config.WebsocketSecurePort;
- } else {
- connUrl += ':' + global.window.mm_config.WebsocketPort;
- }
+ // replace the protocol with a websocket one
+ if (connUrl.startsWith('https:')) {
+ connUrl = connUrl.replace(/^https:/, 'wss:');
+ } else {
+ connUrl = connUrl.replace(/^http:/, 'ws:');
+ }
+
+ // append a port number if one isn't already specified
+ if (!(/:\d+$/).test(connUrl)) {
+ if (connUrl.startsWith('wss:')) {
+ connUrl += ':' + global.window.mm_config.WebsocketSecurePort;
+ } else {
+ connUrl += ':' + global.window.mm_config.WebsocketPort;
}
+ }
- // append the websocket api path
- connUrl += Client.getUsersRoute() + '/websocket';
+ // append the websocket api path
+ connUrl += Client.getUsersRoute() + '/websocket';
- WebSocketClient.setEventCallback(handleEvent);
- WebSocketClient.setFirstConnectCallback(handleFirstConnect);
- WebSocketClient.setReconnectCallback(handleReconnect);
- WebSocketClient.setCloseCallback(handleClose);
- WebSocketClient.initialize(connUrl);
- }
+ WebSocketClient.setEventCallback(handleEvent);
+ WebSocketClient.setFirstConnectCallback(handleFirstConnect);
+ WebSocketClient.setReconnectCallback(handleReconnect);
+ WebSocketClient.setCloseCallback(handleClose);
+ WebSocketClient.initialize(connUrl);
}
export function close() {