Don't clear notifications when refetching

Make the popup header the pending element to give the user a visual
indication that the notification widget is being updated, but don't
clear the notifications before loading more from the database.

Bug: T112186
Change-Id: If2b724fab07ef5b7caf5cab3e44fe326470ac0e7
This commit is contained in:
Moriel Schottlender 2015-09-10 15:24:21 -07:00
parent 957c2b0c98
commit b1b9b6e257
3 changed files with 8 additions and 6 deletions

View file

@ -58,8 +58,6 @@
}
);
this.setPendingElement( this.notificationsWidget.$element );
// Footer
allNotificationsButton = new OO.ui.ButtonWidget( {
framed: false,
@ -106,6 +104,8 @@
this.updateIcon( !!config.hasUnseen );
this.setPendingElement( this.popup.$head );
// Mark all as read button
this.markAllReadButton = new OO.ui.ButtonWidget( {
framed: false,
@ -199,9 +199,6 @@
if ( !this.notificationsModel.isFetchingNotifications() ) {
if ( this.hasRunFirstTime ) {
// Don't clear items on the first time we open the popup
this.notificationsModel.clearItems();
// HACK: Clippable doesn't resize the clippable area when
// it calculates the new size. Since the popup contents changed
// and the popup is "empty" now, we need to manually set its

View file

@ -66,6 +66,7 @@
}
.oo-ui-popupWidget-head {
height: 3.5em;
> .oo-ui-iconWidget {
float: left;
margin: 0.7em 0 1em 1em;

View file

@ -269,6 +269,10 @@
for ( i = 0, len = data.index.length; i < len; i++ ) {
notifData = data.list[ data.index[i] ];
if ( model.getItemById( notifData.id ) ) {
// Skip if we already have the item
continue;
}
// TODO: This should really be formatted better, and the OptionWidget
// should be the one that displays whatever icon relates to this notification
// according to its type.
@ -292,7 +296,7 @@
idArray.push( notifData.id );
optionItems.push( notificationModel );
}
model.addItems( optionItems );
model.addItems( optionItems, 0 );
return idArray;
} )