Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/237522

Change subject: Don't clear notifications when refetching
......................................................................

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
---
M modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
M modules/ooui/styles/mw.echo.ui.NotificationBadgeWidget.less
M modules/viewmodel/mw.echo.dm.NotificationsModel.js
3 files changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/22/237522/1

diff --git a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js 
b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
index caeb795..037e57c 100644
--- a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
+++ b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
@@ -58,8 +58,6 @@
                        }
                );
 
-               this.setPendingElement( this.notificationsWidget.$element );
-
                // Footer
                allNotificationsButton = new OO.ui.ButtonWidget( {
                        framed: false,
@@ -105,6 +103,8 @@
                this.popup.$head.prepend( this.popupHeadIcon.$element );
 
                this.updateIcon( !!config.hasUnseen );
+
+               this.setPendingElement( this.popup.$head );
 
                // Mark all as read button
                this.markAllReadButton = new OO.ui.ButtonWidget( {
@@ -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
diff --git a/modules/ooui/styles/mw.echo.ui.NotificationBadgeWidget.less 
b/modules/ooui/styles/mw.echo.ui.NotificationBadgeWidget.less
index ad214e1..d705a8a 100644
--- a/modules/ooui/styles/mw.echo.ui.NotificationBadgeWidget.less
+++ b/modules/ooui/styles/mw.echo.ui.NotificationBadgeWidget.less
@@ -66,6 +66,7 @@
        }
 
        .oo-ui-popupWidget-head {
+               height: 3.5em;
                > .oo-ui-iconWidget {
                        float: left;
                        margin: 0.7em 0 1em 1em;
diff --git a/modules/viewmodel/mw.echo.dm.NotificationsModel.js 
b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
index ed69a43..1a090db 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationsModel.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
@@ -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;
                                } )

-- 
To view, visit https://gerrit.wikimedia.org/r/237522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2b724fab07ef5b7caf5cab3e44fe326470ac0e7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to