Increase performance when receiving messages (#5375)

Этот коммит содержится в:
Joram Wilander
2017-02-13 09:27:28 -05:00
коммит произвёл Corey Hulen
родитель fac85b676e
Коммит ff741740ee
14 изменённых файлов: 106 добавлений и 64 удалений

Просмотреть файл

@@ -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
});
}

Просмотреть файл

@@ -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,

Просмотреть файл

@@ -145,3 +145,8 @@ export function inviteMembers(data, success, error) {
}
);
}
export function switchTeams(url) {
AsyncClient.viewChannel();
browserHistory.push(url);
}

Просмотреть файл

@@ -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();