Improve client-side unread count estimation

- Remove duplicated counter adjustments.

- Differentiate between all IDs to mark as
  read vs. all IDs that represent visible
  notifications when adjusting the counter.

Change-Id: I1b3e52a929c6e920e3b782c9ef028539b3db0c99
This commit is contained in:
Stephane Bisson 2016-06-21 08:27:39 -04:00
parent b3273d23d7
commit 5a5e1970c5

View file

@ -302,7 +302,7 @@
for ( i = 0; i < items.length; i++ ) {
item = items[ i ];
if ( !item.isRead() ) {
itemIds = itemIds.concat( item.getAllIds() );
itemIds.push( item.getId() );
}
}
@ -410,7 +410,7 @@
notification.toggleRead( isRead );
} );
this.manager.getUnreadCounter().estimateChange( isRead ? -allIds.length : allIds.length );
this.manager.getUnreadCounter().estimateChange( isRead ? -itemIds.length : itemIds.length );
return this.api.markItemsRead( allIds, model.getSource(), isRead ).then( this.refreshUnreadCount.bind( this ) );
};
@ -484,7 +484,6 @@
// Synchronously remove this model from the widget
controller.removeCrossWikiItem();
controller.manager.counter.estimateChange( -itemCounter );
return mw.echo.api.NetworkHandler.static.waitForAllPromises( promises );
} );
};