Mooeypoo has uploaded a new change for review.

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

Change subject: Initialize notifications model outside of the widget
......................................................................

Initialize notifications model outside of the widget

Change-Id: I19c239326b04eaa07b62e0b06f181c86ff0a0ef8
---
M modules/ext.echo.init.js
M modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
2 files changed, 29 insertions(+), 14 deletions(-)


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

diff --git a/modules/ext.echo.init.js b/modules/ext.echo.init.js
index a40f819..2b226da 100644
--- a/modules/ext.echo.init.js
+++ b/modules/ext.echo.init.js
@@ -53,9 +53,22 @@
 
                        // Load the ui
                        mw.loader.using( 'ext.echo.ui', function () {
+                               var messageNotificationsModel, 
alertNotificationsModel;
+
                                // Load message button and popup if messages 
exist
                                if ( $existingMessageLink.length ) {
-                                       mw.echo.ui.messageWidget = new 
mw.echo.ui.NotificationBadgeWidget( {
+                                       messageNotificationsModel = new 
mw.echo.dm.NotificationsModel(
+                                               new mw.echo.dm.APIHandler( {
+                                                       type: 'message',
+                                                       limit: 25,
+                                                       userLang: 
mw.config.get( 'wgUserLanguage' ),
+                                                       baseParams: 
mw.echo.apiCallParams
+                                               } ),
+                                               {
+                                                       type: 'message'
+                                               }
+                                       );
+                                       mw.echo.ui.messageWidget = new 
mw.echo.ui.NotificationBadgeWidget( messageNotificationsModel, {
                                                type: 'message',
                                                markReadWhenSeen: false,
                                                numItems: numMessages,
@@ -78,7 +91,18 @@
                                }
 
                                // Load alerts popup and button
-                               mw.echo.ui.alertWidget = new 
mw.echo.ui.NotificationBadgeWidget( {
+                               alertNotificationsModel = new 
mw.echo.dm.NotificationsModel(
+                                       new mw.echo.dm.APIHandler( {
+                                               type: 'alert',
+                                               limit: 25,
+                                               userLang: mw.config.get( 
'wgUserLanguage' ),
+                                               baseParams: 
mw.echo.apiCallParams
+                                       } ),
+                                       {
+                                               type: 'alert'
+                                       }
+                               );
+                               mw.echo.ui.alertWidget = new 
mw.echo.ui.NotificationBadgeWidget( alertNotificationsModel, {
                                        type: 'alert',
                                        markReadWhenSeen: true,
                                        numItems: numAlerts,
diff --git a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js 
b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
index 3d764f6..21585e0 100644
--- a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
+++ b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
@@ -6,6 +6,7 @@
         * @extends OO.ui.ButtonWidget
         *
         * @constructor
+        * @param {mw.echo.dm.NotificationsModel} model Notifications view model
         * @param {Object} [config] Configuration object
         * @cfg {string} [type='alert'] Notification type 'alert' or 'message'
         * @cfg {number} [numItems=0] How many items are in the button display
@@ -22,7 +23,7 @@
         *  } }
         * @cfg {string} [href] URL the badge links to
         */
-       mw.echo.ui.NotificationBadgeWidget = function 
MwEchoUiNotificationBadgeButtonPopupWidget( config ) {
+       mw.echo.ui.NotificationBadgeWidget = function 
MwEchoUiNotificationBadgeButtonPopupWidget( model, config ) {
                var buttonFlags, allNotificationsButton, preferencesButton, 
footerButtonGroupWidget, $footer;
 
                config = config || {};
@@ -58,17 +59,7 @@
                } );
 
                // View model
-               this.notificationsModel = new mw.echo.dm.NotificationsModel(
-                       new mw.echo.dm.APIHandler( {
-                               type: this.type,
-                               limit: 25,
-                               userLang: mw.config.get( 'wgUserLanguage' ),
-                               baseParams: mw.echo.apiCallParams
-                       } ),
-                       {
-                               type: this.type
-                       }
-               );
+               this.notificationsModel = model;
 
                // Notifications widget
                this.notificationsWidget = new mw.echo.ui.NotificationsWidget(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19c239326b04eaa07b62e0b06f181c86ff0a0ef8
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