@@ -217,22 +217,30 @@ var RoomSubList = React.createClass({
217
217
return roomNotifState != RoomNotifs . MUTE ;
218
218
} ,
219
219
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 ) {
221
227
var self = this ;
222
228
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 ( ) ;
227
234
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 ;
231
238
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
+ }
236
244
}
237
245
}
238
246
return result ;
@@ -423,11 +431,25 @@ var RoomSubList = React.createClass({
423
431
424
432
_createOverflowTile : function ( overflowCount , totalCount ) {
425
433
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
+
426
448
return (
427
449
< div className = "mx_RoomSubList_ellipsis" onClick = { this . _showFullMemberList } >
428
450
< div className = "mx_RoomSubList_line" > </ div >
429
451
< div className = "mx_RoomSubList_more" > more</ div >
430
- < div className = "mx_RoomSubList_moreBadge" > { content } </ div >
452
+ < div className = { badgeClasses } > { content } </ div >
431
453
</ div >
432
454
) ;
433
455
} ,
0 commit comments