Skip to content

Commit 7af7659

Browse files
committed
Notification counts now done correctly, as well as highlights
1 parent 72e108c commit 7af7659

File tree

2 files changed

+55
-18
lines changed

2 files changed

+55
-18
lines changed

src/components/structures/RoomSubList.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,30 @@ var RoomSubList = React.createClass({
217217
return roomNotifState != RoomNotifs.MUTE;
218218
},
219219

220-
roomNotificationCount: function() {
220+
/**
221+
* Total up all the notification counts from the rooms
222+
*
223+
* @param {Number} If supplied will only total notifications for rooms outside the truncation number
224+
* @returns {Array} The array takes the form [total, highlight] where highlight is a bool
225+
*/
226+
roomNotificationCount: function(truncateAt) {
221227
var self = this;
222228

223-
return this.props.list.reduce(function(result, room) {
224-
var roomNotifState = RoomNotifs.getRoomNotifsState(room.roomId);
225-
var highlight = room.getUnreadNotificationCount('highlight') > 0 || self.props.label === 'Invites';
226-
var notificationCount = room.getUnreadNotificationCount();
229+
return this.props.list.reduce(function(result, room, index) {
230+
if (truncateAt === undefined || index >= truncateAt) {
231+
var roomNotifState = RoomNotifs.getRoomNotifsState(room.roomId);
232+
var highlight = room.getUnreadNotificationCount('highlight') > 0 || self.props.label === 'Invites';
233+
var notificationCount = room.getUnreadNotificationCount();
227234

228-
const notifBadges = notificationCount > 0 && self._shouldShowNotifBadge(roomNotifState);
229-
const mentionBadges = highlight && self._shouldShowMentionBadge(roomNotifState);
230-
const badges = notifBadges || mentionBadges;
235+
const notifBadges = notificationCount > 0 && self._shouldShowNotifBadge(roomNotifState);
236+
const mentionBadges = highlight && self._shouldShowMentionBadge(roomNotifState);
237+
const badges = notifBadges || mentionBadges;
231238

232-
if (badges) {
233-
result[0] += notificationCount;
234-
if (highlight) {
235-
result[1] = true;
239+
if (badges) {
240+
result[0] += notificationCount;
241+
if (highlight) {
242+
result[1] = true;
243+
}
236244
}
237245
}
238246
return result;
@@ -423,11 +431,25 @@ var RoomSubList = React.createClass({
423431

424432
_createOverflowTile: function(overflowCount, totalCount) {
425433
var content = <div className="mx_RoomSubList_chevronDown"></div>;
434+
435+
var overflowNotifications = this.roomNotificationCount(TRUNCATE_AT);
436+
var overflowNotifCount = overflowNotifications[0];
437+
var overflowNotifHighlight = overflowNotifications[1];
438+
if (overflowNotifCount && !this.props.collapsed) {
439+
content = overflowNotifCount;
440+
}
441+
442+
var badgeClasses = classNames({
443+
'mx_RoomSubList_moreBadge': true,
444+
'mx_RoomSubList_moreBadgeNotify': overflowNotifCount && !this.props.collapsed,
445+
'mx_RoomSubList_moreBadgeHighlight': overflowNotifHighlight && !this.props.collapsed,
446+
});
447+
426448
return (
427449
<div className="mx_RoomSubList_ellipsis" onClick={this._showFullMemberList}>
428450
<div className="mx_RoomSubList_line"></div>
429451
<div className="mx_RoomSubList_more">more</div>
430-
<div className="mx_RoomSubList_moreBadge">{ content }</div>
452+
<div className={ badgeClasses }>{ content }</div>
431453
</div>
432454
);
433455
},

src/skins/vector/css/vector-web/structures/RoomSubList.css

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,14 @@ limitations under the License.
152152
.mx_RoomSubList_ellipsis {
153153
display: block;
154154
line-height: 11px;
155-
height: auto;
156-
margin-bottom: 4px;
155+
height: 18px;
157156
position: relative;
158157
cursor: pointer;
159158
font-size: 13px;
160159
}
161160

162161
.collapsed .mx_RoomSubList_ellipsis {
163-
height: 16px;
162+
height: 20px;
164163
}
165164

166165
.mx_RoomSubList_line {
@@ -205,12 +204,28 @@ limitations under the License.
205204
font-size: 10px;
206205
text-align: center;
207206
padding-top: 1px;
208-
padding-left: 4px;
209-
padding-right: 4px;
207+
padding-left: 3px;
208+
padding-right: 3px;
210209
background-color: #fff;
211210
vertical-align: middle;
212211
}
213212

213+
.mx_RoomSubList_moreBadge.mx_RoomSubList_moreBadgeNotify {
214+
background-color: #76cfa6;
215+
border: 0;
216+
padding-top: 3px;
217+
padding-left: 4px;
218+
padding-right: 4px;
219+
}
220+
221+
.mx_RoomSubList_moreBadge.mx_RoomSubList_moreBadgeHighlight {
222+
background-color: #ff0064;
223+
border: 0;
224+
padding-top: 3px;
225+
padding-left: 4px;
226+
padding-right: 4px;
227+
}
228+
214229
.collapsed .mx_RoomSubList_moreBadge {
215230
position: static;
216231
margin-left: 16px;

0 commit comments

Comments
 (0)