jenkins-bot has submitted this change and it was merged.

Change subject: Update notifications when reopening the popup
......................................................................


Update notifications when reopening the popup

When reopening the popup, update the notification list to reflect
changes.

Bug: T127027
Change-Id: I6c3e948293b7c25cfab37f96b1faaca844014c28
---
M modules/viewmodel/mw.echo.dm.NotificationsModel.js
1 file changed, 16 insertions(+), 11 deletions(-)

Approvals:
  Sbisson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/viewmodel/mw.echo.dm.NotificationsModel.js 
b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
index 17490be..dba2eaf 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationsModel.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
@@ -45,6 +45,7 @@
 
                this.markingAllAsRead = false;
                this.autoMarkReadInProcess = false;
+               this.fetchingNotifications = false;
 
                this.removeReadNotifications = !!config.removeReadNotifications;
                this.foreign = !!config.foreign;
@@ -484,14 +485,6 @@
                                                notifData = data.list[ id ];
                                                content = notifData[ '*' ] || 
{};
 
-                                               if ( model.getItemById( id ) ) {
-                                                       // Skip if we already 
have the item
-                                                       // TODO: Instead of 
skipping, we should consider repopulating
-                                                       // the item, in case 
there are any changes that would result
-                                                       // in 
repositioning/resorting in the future.
-                                                       continue;
-                                               }
-
                                                // Collect common data
                                                newNotifData = {
                                                        read: !!notifData.read,
@@ -547,7 +540,16 @@
                                                optionItems.push( 
notificationModel );
                                        }
 
-                                       // Add to the model
+                                       // Empty current items
+                                       // HACK: We're turning on a 
'fetchingNotifications' flag
+                                       // so the x-wiki "empty" event is 
suppressed while
+                                       // we clear items just to fill them 
back up.
+                                       // Otherwise, the x-wiki notification 
bundle will be
+                                       // removed from the general list before 
it is refilled.
+                                       model.fetchingNotifications = true;
+                                       model.clearItems();
+                                       model.fetchingNotifications = false;
+                                       // Add again to the model
                                        model.addItems( optionItems, 0 );
 
                                        model.emit( 'done', true, { ids: 
idArray } );
@@ -602,7 +604,7 @@
                // Parent
                mw.echo.dm.SortedList.prototype.removeItems.call( this, items );
 
-               if ( this.isEmpty() ) {
+               if ( this.isEmpty() && !this.fetchingNotifications ) {
                        this.emit( 'empty' );
                }
        };
@@ -615,7 +617,10 @@
 
                // Parent
                mw.echo.dm.SortedList.prototype.clearItems.call( this );
-               this.emit( 'empty' );
+
+               if ( !this.fetchingNotifications ) {
+                       this.emit( 'empty' );
+               }
        };
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6c3e948293b7c25cfab37f96b1faaca844014c28
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to