summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-13 09:27:28 -0500
committerCorey Hulen <corey@hulen.com>2017-02-13 09:27:28 -0500
commitff741740eebceb43b1d69b13d97ae7eed2aa32d1 (patch)
tree0f795cea935a72997bf3618ceaf3b0513d5e8096 /webapp/actions
parentfac85b676eafb20b5f70db1805006d64889606ff (diff)
downloadchat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.tar.gz
chat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.tar.bz2
chat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.zip
Increase performance when receiving messages (#5375)
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/global_actions.jsx7
-rw-r--r--webapp/actions/post_actions.jsx20
-rw-r--r--webapp/actions/team_actions.jsx5
-rw-r--r--webapp/actions/websocket_actions.jsx13
4 files changed, 9 insertions, 36 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index 2d1638060..5def48858 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -47,16 +47,17 @@ export function emitChannelClickEvent(channel) {
function switchToChannel(chan) {
const channelMember = ChannelStore.getMyMember(chan.id);
const getMyChannelMembersPromise = AsyncClient.getChannelMember(chan.id, UserStore.getCurrentId());
+ const oldChannelId = ChannelStore.getCurrentId();
getMyChannelMembersPromise.then(() => {
AsyncClient.getChannelStats(chan.id, true);
- AsyncClient.viewChannel(chan.id, ChannelStore.getCurrentId());
+ AsyncClient.viewChannel(chan.id, oldChannelId);
loadPosts(chan.id);
trackPage();
});
// Mark previous and next channel as read
- ChannelStore.resetCounts(ChannelStore.getCurrentId());
+ ChannelStore.resetCounts(oldChannelId);
ChannelStore.resetCounts(chan.id);
BrowserStore.setGlobalItem(chan.team_id, chan.id);
@@ -68,7 +69,7 @@ export function emitChannelClickEvent(channel) {
team_id: chan.team_id,
total_msg_count: chan.total_msg_count,
channelMember,
- prev: ChannelStore.getCurrentId()
+ prev: oldChannelId
});
}
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index 61f193b66..633a6f66a 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -5,7 +5,6 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import PostStore from 'stores/post_store.jsx';
-import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {loadStatusesForChannel} from 'actions/status_actions.jsx';
@@ -18,30 +17,11 @@ const ActionTypes = Constants.ActionTypes;
const Preferences = Constants.Preferences;
export function handleNewPost(post, msg) {
- const teamId = TeamStore.getCurrentId();
-
- if (ChannelStore.getCurrentId() === post.channel_id) {
- if (window.isActive) {
- AsyncClient.viewChannel();
- } else {
- AsyncClient.getChannel(post.channel_id);
- }
- } else if (msg && (teamId === msg.data.team_id || msg.data.channel_type === Constants.DM_CHANNEL)) {
- if (Client.teamId) {
- AsyncClient.getChannel(post.channel_id);
- }
- }
-
let websocketMessageProps = null;
if (msg) {
websocketMessageProps = msg.data;
}
- const myTeams = TeamStore.getMyTeamMembers();
- if (msg.data.team_id !== teamId && myTeams.filter((m) => m.team_id === msg.data.team_id).length) {
- AsyncClient.getMyTeamsUnread(teamId);
- }
-
if (post.root_id && PostStore.getPost(post.channel_id, post.root_id) == null) {
Client.getPost(
post.channel_id,
diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx
index e23fe1e5d..478d3dffc 100644
--- a/webapp/actions/team_actions.jsx
+++ b/webapp/actions/team_actions.jsx
@@ -145,3 +145,8 @@ export function inviteMembers(data, success, error) {
}
);
}
+
+export function switchTeams(url) {
+ AsyncClient.viewChannel();
+ browserHistory.push(url);
+}
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 3f3e81d16..2e95c712c 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -137,10 +137,6 @@ function handleEvent(msg) {
handleUserUpdatedEvent(msg);
break;
- case SocketEvents.CHANNEL_VIEWED:
- handleChannelViewedEvent(msg);
- break;
-
case SocketEvents.CHANNEL_DELETED:
handleChannelDeletedEvent(msg);
break;
@@ -282,15 +278,6 @@ function handleUserUpdatedEvent(msg) {
}
}
-function handleChannelViewedEvent(msg) {
- // Useful for when multiple devices have the app open to different channels
- if (TeamStore.getCurrentId() === msg.broadcast.team_id &&
- ChannelStore.getCurrentId() !== msg.data.channel_id &&
- UserStore.getCurrentId() === msg.broadcast.user_id) {
- AsyncClient.getChannel(msg.data.channel_id);
- }
-}
-
function handleChannelDeletedEvent(msg) {
if (ChannelStore.getCurrentId() === msg.data.channel_id) {
const teamUrl = TeamStore.getCurrentTeamRelativeUrl();