Increase performance when receiving messages (#5375)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
fac85b676e
Коммит
ff741740ee
@@ -392,6 +392,31 @@ class ChannelStoreClass extends EventEmitter {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
incrementMessages(id) {
|
||||
if (!this.unreadCounts[id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.unreadCounts[id].msgs++;
|
||||
this.get(id).total_msg_count++;
|
||||
}
|
||||
|
||||
incrementMentionsIfNeeded(id, msgProps) {
|
||||
let mentions = [];
|
||||
if (msgProps && msgProps.mentions) {
|
||||
mentions = JSON.parse(msgProps.mentions);
|
||||
}
|
||||
|
||||
if (!this.unreadCounts[id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mentions.indexOf(UserStore.getCurrentId()) !== -1) {
|
||||
this.unreadCounts[id].mentions++;
|
||||
this.getMyMember(id).mention_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ChannelStore = new ChannelStoreClass();
|
||||
@@ -469,6 +494,18 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||
ChannelStore.emitStatsChange();
|
||||
break;
|
||||
|
||||
case ActionTypes.RECEIVED_POST:
|
||||
var id = action.post.channel_id;
|
||||
var teamId = action.websocketMessageProps ? action.websocketMessageProps.team_id : '';
|
||||
|
||||
// Current team and not current channel or the window is inactive
|
||||
if (TeamStore.getCurrentId() === teamId && (ChannelStore.getCurrentId() !== id || !window.isActive)) {
|
||||
ChannelStore.incrementMessages(id);
|
||||
ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
|
||||
ChannelStore.emitChange();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -316,6 +316,23 @@ class TeamStoreClass extends EventEmitter {
|
||||
member.mention_count -= channelMember.mention_count;
|
||||
}
|
||||
}
|
||||
|
||||
incrementMessages(id) {
|
||||
const member = this.my_team_members.filter((m) => m.team_id === id)[0];
|
||||
member.msg_count++;
|
||||
}
|
||||
|
||||
incrementMentionsIfNeeded(id, msgProps) {
|
||||
let mentions = [];
|
||||
if (msgProps && msgProps.mentions) {
|
||||
mentions = JSON.parse(msgProps.mentions);
|
||||
}
|
||||
|
||||
if (mentions.indexOf(UserStore.getCurrentId()) !== -1) {
|
||||
const member = this.my_team_members.filter((m) => m.team_id === id)[0];
|
||||
member.mention_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var TeamStore = new TeamStoreClass();
|
||||
@@ -370,6 +387,14 @@ TeamStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||
TeamStore.emitUnreadChange();
|
||||
}
|
||||
break;
|
||||
case ActionTypes.RECEIVED_POST:
|
||||
var id = action.websocketMessageProps ? action.websocketMessageProps.team_id : '';
|
||||
if (TeamStore.getCurrentId() !== id && id.length > 0) {
|
||||
TeamStore.incrementMessages(id);
|
||||
TeamStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
|
||||
TeamStore.emitChange();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
});
|
||||
|
||||
Ссылка в новой задаче
Block a user