summaryrefslogtreecommitdiffstats
path: root/webapp/action_creators/global_actions.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-23 10:20:52 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-23 10:38:35 -0400
commit9239a7353af2c67a6778ff4cabd164db62087bde (patch)
tree78335a5254885058ed3b224a4b050db03c732bb3 /webapp/action_creators/global_actions.jsx
parent6568e15023c009c96a46f022236f5fd4415445c0 (diff)
downloadchat-9239a7353af2c67a6778ff4cabd164db62087bde.tar.gz
chat-9239a7353af2c67a6778ff4cabd164db62087bde.tar.bz2
chat-9239a7353af2c67a6778ff4cabd164db62087bde.zip
Fixing websocket connection issue. Refactoring websockets into an action creator.
Diffstat (limited to 'webapp/action_creators/global_actions.jsx')
-rw-r--r--webapp/action_creators/global_actions.jsx34
1 files changed, 32 insertions, 2 deletions
diff --git a/webapp/action_creators/global_actions.jsx b/webapp/action_creators/global_actions.jsx
index 0280d5974..ab38532a6 100644
--- a/webapp/action_creators/global_actions.jsx
+++ b/webapp/action_creators/global_actions.jsx
@@ -10,6 +10,7 @@ const ActionTypes = Constants.ActionTypes;
import * as AsyncClient from 'utils/async_client.jsx';
import * as Client from 'utils/client.jsx';
import * as Utils from 'utils/utils.jsx';
+import * as Websockets from './websocket_actions.jsx';
import * as I18n from 'i18n/i18n.jsx';
import en from 'i18n/en.json';
@@ -97,10 +98,21 @@ export function emitLoadMorePostsFocusedBottomEvent() {
AsyncClient.getPostsAfter(latestPostId, 0, Constants.POST_CHUNK_SIZE);
}
-export function emitPostRecievedEvent(post) {
+export function emitPostRecievedEvent(post, websocketMessageProps) {
+ if (ChannelStore.getCurrentId() === post.channel_id) {
+ if (window.isActive) {
+ AsyncClient.updateLastViewedAt();
+ } else {
+ AsyncClient.getChannel(post.channel_id);
+ }
+ } else {
+ AsyncClient.getChannel(post.channel_id);
+ }
+
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_POST,
- post
+ post,
+ websocketMessageProps
});
}
@@ -261,3 +273,21 @@ export function viewLoggedIn() {
// Clear pending posts (shouldn't have pending posts if we are loading)
PostStore.clearPendingPosts();
}
+
+var lastTimeTypingSent = 0;
+export function emitLocalUserTypingEvent(channelId, parentId) {
+ const t = Date.now();
+ if ((t - lastTimeTypingSent) > Constants.UPDATE_TYPING_MS) {
+ Websockets.sendMessage({channel_id: channelId, action: 'typing', props: {parent_id: parentId}, state: {}});
+ lastTimeTypingSent = t;
+ }
+}
+
+export function emitRemoteUserTypingEvent(channelId, userId, postParentId) {
+ AppDispatcher.handleViewAction({
+ type: Constants.ActionTypes.USER_TYPING,
+ channelId,
+ userId,
+ postParentId
+ });
+}