From a88fe8ea1a9cc020cc0d1dc442d46fc0bed90cc9 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Mon, 26 Oct 2015 17:53:21 +0100 Subject: rename methods and varibles to a more meaningful name --- web/react/components/sidebar.jsx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx index 0d3577f2d..5cb6d168b 100644 --- a/web/react/components/sidebar.jsx +++ b/web/react/components/sidebar.jsx @@ -41,7 +41,7 @@ export default class Sidebar extends React.Component { this.createChannelElement = this.createChannelElement.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.isLeaving = new Map(); @@ -51,14 +51,15 @@ export default class Sidebar extends React.Component { state.showDirectChannelsModal = false; state.loadingDMChannel = -1; state.windowWidth = Utils.windowWidth(); - - this.unreadCount = this.setUnreadCount(); this.state = state; + + this.unreadCountPerChannel = {}; + this.setUnreadCountPerChannel(); } - setUnreadCount() { + setUnreadCountPerChannel() { const channels = ChannelStore.getAll(); const members = ChannelStore.getAllMembers(); - const unreadCount = {}; + const channelUnreadCounts = {}; channels.forEach((ch) => { const chMember = members[ch.id]; @@ -70,22 +71,22 @@ export default class Sidebar extends React.Component { chUnreadCount = 0; } - unreadCount[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount}; + channelUnreadCounts[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount}; }); - return unreadCount; + this.unreadCountPerChannel = channelUnreadCounts; } getUnreadCount(channelId) { let mentions = 0; let msgs = 0; 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) => { - msgs += this.unreadCount[chId].msgs; - mentions += this.unreadCount[chId].mentions; + Object.keys(this.unreadCountPerChannel).forEach((chId) => { + msgs += this.unreadCountPerChannel[chId].msgs; + mentions += this.unreadCountPerChannel[chId].mentions; }); return {msgs, mentions}; @@ -469,7 +470,7 @@ export default class Sidebar extends React.Component { render() { 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 this.firstUnreadChannel = null; -- cgit v1.2.3-1-g7c22