Properly aggregate the itemUpdate event

Instead of 'cheating' and externally aggregating the itemUpdate event
we should just let the relevant (non-xwiki) models aggregate this
centrally and properly, and include it as an offered event.

Change-Id: Ibe528fe971e1be8309a97275b1a1be8979306ff5
This commit is contained in:
Moriel Schottlender 2016-07-06 14:11:10 -07:00 committed by Mooeypoo
parent ebd616d6f3
commit 5c81ac8d3b
4 changed files with 10 additions and 5 deletions

View file

@ -36,7 +36,6 @@
this.list = new mw.echo.dm.NotificationsList();
this.list.setItems( bundledNotificationModels );
this.list.aggregate( { update: 'itemUpdate' } );
this.list.connect( this, { itemUpdate: 'onItemUpdate' } );
// For bundles, 'read' is a computed state based on

View file

@ -112,7 +112,6 @@
localModel = this.getNotificationModel( 'local' );
if ( localModel ) {
localModel.aggregate( { update: 'itemUpdate' } );
localModel.connect( this, { itemUpdate: 'checkLocalUnreadTalk' } );
}

View file

@ -55,6 +55,9 @@
// Fallback on IDs
return b.getId() - a.getId();
} );
// Events
this.aggregate( { update: 'itemUpdate' } );
};
/* Initialization */
@ -69,6 +72,13 @@
* The list has been updated
*/
/**
* @event itemUpdate
* @param {mw.echo.dm.NotificationItem} item Item that has changed
*
* An item in the list has been updated
*/
/* Methods */
/**

View file

@ -85,9 +85,6 @@
// Update all items
update: 'resetItemsFromModel'
} );
// We must aggregate on item update, so we know when and if all
// items are read and can hide/show the 'mark all read' button
this.model.aggregate( { update: 'itemUpdate' } );
this.model.connect( this, { itemUpdate: 'toggleMarkAllReadButton' } );
this.markAllReadButton.connect( this, { click: 'onMarkAllReadButtonClick' } );