From eea0dea7ce1c6a498ff8ee0a7fd2f661a955d0ee Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Thu, 7 Jul 2016 16:29:40 -0700 Subject: [PATCH] Only fetch 'unreadfirst' for the Popup, not Special:Notifications We need the API to return the notifications for the special page in timestamp order and not read/unread order, so that the 'continue' value is still correct. On top of that, if we have many unread notifications, they should still be placed according to the dates, so the API must bring back proper result. In this fix, we add 'unreadFirst' to filters, and only use that filter when needed (namely, in the popup) Bug: T136885 Change-Id: I3018d09b009d735402d83074a5ffcd14ea1c242a --- modules/api/mw.echo.api.APIHandler.js | 1 - modules/api/mw.echo.api.EchoApi.js | 6 ++++++ modules/controller/mw.echo.Controller.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/api/mw.echo.api.APIHandler.js b/modules/api/mw.echo.api.APIHandler.js index 213e87a01..d802287f1 100644 --- a/modules/api/mw.echo.api.APIHandler.js +++ b/modules/api/mw.echo.api.APIHandler.js @@ -119,7 +119,6 @@ notsections: this.normalizedType[ type ], notformat: 'model', notlimit: this.limit, - notunreadfirst: 1, notprop: 'list|count', uselang: this.userLang }, this.getTypeParams( type ) ); diff --git a/modules/api/mw.echo.api.EchoApi.js b/modules/api/mw.echo.api.EchoApi.js index 11e224813..4dcf3195c 100644 --- a/modules/api/mw.echo.api.EchoApi.js +++ b/modules/api/mw.echo.api.EchoApi.js @@ -98,6 +98,8 @@ * defining the offset to fetch notifications * @param {string} [filterObject.readState] Notification read * state, 'all', 'read' or 'unread' + * @param {boolean} [filterObject.unreadFirst] Fetch unread notifications + * first in the sorting order. * @param {string|string[]} [filterObject.titles] Requested titles. To request notifications with no title, * use null (standalone or as an array element). * @return {Object} API parameter definitions to override @@ -114,6 +116,10 @@ overrideParams.notcontinue = filterObject.continue; } + if ( filterObject.unreadFirst ) { + overrideParams.notunreadfirst = 1; + } + if ( filterObject.readState && filterObject.readState !== 'all' ) { overrideParams.notfilter = filterObject.readState === 'read' ? 'read' : diff --git a/modules/controller/mw.echo.Controller.js b/modules/controller/mw.echo.Controller.js index a6a1041a7..5cc7a4502 100644 --- a/modules/controller/mw.echo.Controller.js +++ b/modules/controller/mw.echo.Controller.js @@ -226,7 +226,7 @@ // between local notifications and x-wiki notifications // until the backend gives us the x-wiki notifications as // part of the original response. - return this.api.fetchNotifications( this.manager.getTypeString(), 'local', !!isForced ) + return this.api.fetchNotifications( this.manager.getTypeString(), 'local', !!isForced, { unreadFirst: true } /* filters */ ) .then( // Success function ( data ) {