rename methods and varibles to a more meaningful name
Этот коммит содержится в:
@@ -41,7 +41,7 @@ export default class Sidebar extends React.Component {
|
|||||||
|
|
||||||
this.createChannelElement = this.createChannelElement.bind(this);
|
this.createChannelElement = this.createChannelElement.bind(this);
|
||||||
this.updateTitle = this.updateTitle.bind(this);
|
this.updateTitle = this.updateTitle.bind(this);
|
||||||
this.setUnreadCount = this.setUnreadCount.bind(this);
|
this.setUnreadCountPerChannel = this.setUnreadCountPerChannel.bind(this);
|
||||||
this.getUnreadCount = this.getUnreadCount.bind(this);
|
this.getUnreadCount = this.getUnreadCount.bind(this);
|
||||||
|
|
||||||
this.isLeaving = new Map();
|
this.isLeaving = new Map();
|
||||||
@@ -51,14 +51,15 @@ export default class Sidebar extends React.Component {
|
|||||||
state.showDirectChannelsModal = false;
|
state.showDirectChannelsModal = false;
|
||||||
state.loadingDMChannel = -1;
|
state.loadingDMChannel = -1;
|
||||||
state.windowWidth = Utils.windowWidth();
|
state.windowWidth = Utils.windowWidth();
|
||||||
|
|
||||||
this.unreadCount = this.setUnreadCount();
|
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
|
this.unreadCountPerChannel = {};
|
||||||
|
this.setUnreadCountPerChannel();
|
||||||
}
|
}
|
||||||
setUnreadCount() {
|
setUnreadCountPerChannel() {
|
||||||
const channels = ChannelStore.getAll();
|
const channels = ChannelStore.getAll();
|
||||||
const members = ChannelStore.getAllMembers();
|
const members = ChannelStore.getAllMembers();
|
||||||
const unreadCount = {};
|
const channelUnreadCounts = {};
|
||||||
|
|
||||||
channels.forEach((ch) => {
|
channels.forEach((ch) => {
|
||||||
const chMember = members[ch.id];
|
const chMember = members[ch.id];
|
||||||
@@ -70,22 +71,22 @@ export default class Sidebar extends React.Component {
|
|||||||
chUnreadCount = 0;
|
chUnreadCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unreadCount[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount};
|
channelUnreadCounts[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount};
|
||||||
});
|
});
|
||||||
|
|
||||||
return unreadCount;
|
this.unreadCountPerChannel = channelUnreadCounts;
|
||||||
}
|
}
|
||||||
getUnreadCount(channelId) {
|
getUnreadCount(channelId) {
|
||||||
let mentions = 0;
|
let mentions = 0;
|
||||||
let msgs = 0;
|
let msgs = 0;
|
||||||
|
|
||||||
if (channelId) {
|
if (channelId) {
|
||||||
return this.unreadCount[channelId] ? this.unreadCount[channelId] : {msgs, mentions};
|
return this.unreadCountPerChannel[channelId] ? this.unreadCountPerChannel[channelId] : {msgs, mentions};
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(this.unreadCount).forEach((chId) => {
|
Object.keys(this.unreadCountPerChannel).forEach((chId) => {
|
||||||
msgs += this.unreadCount[chId].msgs;
|
msgs += this.unreadCountPerChannel[chId].msgs;
|
||||||
mentions += this.unreadCount[chId].mentions;
|
mentions += this.unreadCountPerChannel[chId].mentions;
|
||||||
});
|
});
|
||||||
|
|
||||||
return {msgs, mentions};
|
return {msgs, mentions};
|
||||||
@@ -469,7 +470,7 @@ export default class Sidebar extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
this.badgesActive = false;
|
this.badgesActive = false;
|
||||||
|
|
||||||
this.unreadCount = this.setUnreadCount();
|
this.setUnreadCountPerChannel();
|
||||||
|
|
||||||
// keep track of the first and last unread channels so we can use them to set the unread indicators
|
// keep track of the first and last unread channels so we can use them to set the unread indicators
|
||||||
this.firstUnreadChannel = null;
|
this.firstUnreadChannel = null;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user