mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Remove order dependency on channels and channel members plus logging (#4370)
This commit is contained in:
@@ -150,11 +150,11 @@ class ChannelStoreClass extends EventEmitter {
|
||||
|
||||
resetCounts(id) {
|
||||
const cm = this.myChannelMembers;
|
||||
for (var cmid in cm) {
|
||||
for (const cmid in cm) {
|
||||
if (cm[cmid].channel_id === id) {
|
||||
var c = this.get(id);
|
||||
if (c) {
|
||||
cm[cmid].msg_count = this.get(id).total_msg_count;
|
||||
const channel = this.get(id);
|
||||
if (channel) {
|
||||
cm[cmid].msg_count = channel.total_msg_count;
|
||||
cm[cmid].mention_count = 0;
|
||||
this.setUnreadCountByChannel(id);
|
||||
}
|
||||
@@ -290,10 +290,26 @@ class ChannelStoreClass extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
setUnreadCountsByChannels(channels) {
|
||||
channels.forEach((c) => {
|
||||
this.setUnreadCountByChannel(c.id);
|
||||
});
|
||||
}
|
||||
|
||||
setUnreadCountByChannel(id) {
|
||||
const ch = this.get(id);
|
||||
const chMember = this.getMyMember(id);
|
||||
|
||||
if (ch == null) {
|
||||
console.log('setUnreadCountByChannel: missing channel id ' + id); //eslint-disable-line no-console
|
||||
return;
|
||||
}
|
||||
|
||||
if (chMember == null) {
|
||||
console.log('setUnreadCountByChannel: missing channel member for channel id ' + id); //eslint-disable-line no-console
|
||||
return;
|
||||
}
|
||||
|
||||
const chMentionCount = chMember.mention_count;
|
||||
let chUnreadCount = ch.total_msg_count - chMember.msg_count;
|
||||
|
||||
@@ -367,6 +383,7 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||
|
||||
case ActionTypes.RECEIVED_CHANNELS:
|
||||
ChannelStore.storeChannels(action.channels);
|
||||
ChannelStore.setUnreadCountsByChannels(action.channels);
|
||||
ChannelStore.emitChange();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user