diff --git a/modules/api/mw.echo.api.APIHandler.js b/modules/api/mw.echo.api.APIHandler.js index ad45ceaf1..06760ae25 100644 --- a/modules/api/mw.echo.api.APIHandler.js +++ b/modules/api/mw.echo.api.APIHandler.js @@ -182,6 +182,7 @@ /** * Mark all notifications as read * + * @param {string} source Wiki name * @param {string|string[]} type Notification type 'message', 'alert' or 'all'. * @return {jQuery.Promise} A promise that resolves when all notifications * are marked as read. @@ -192,6 +193,7 @@ * Mark multiple notification items as read using specific IDs * * @abstract + * @param {string} source Wiki name * @param {string[]} itemIdArray An array of notification item IDs * @param {boolean} [isRead] Item's new read state; true for marking the item * as read, false for marking the item as unread diff --git a/modules/api/mw.echo.api.EchoApi.js b/modules/api/mw.echo.api.EchoApi.js index 44992183c..80163d22e 100644 --- a/modules/api/mw.echo.api.EchoApi.js +++ b/modules/api/mw.echo.api.EchoApi.js @@ -239,7 +239,8 @@ * for that type in the given source */ mw.echo.api.EchoApi.prototype.markItemsRead = function ( itemIds, source, isRead ) { - return this.network.getApiHandler( source ).markItemsRead( itemIds, isRead ); + // markasread is proxied via the local API + return this.network.getApiHandler( 'local' ).markItemsRead( source, itemIds, isRead ); }; /** @@ -252,7 +253,8 @@ * for that type in the given source */ mw.echo.api.EchoApi.prototype.markAllRead = function ( source, type ) { - return this.network.getApiHandler( source ).markAllRead( type ); + // markasread is proxied via the local API + return this.network.getApiHandler( 'local' ).markAllRead( source, type ); }; /** diff --git a/modules/api/mw.echo.api.LocalAPIHandler.js b/modules/api/mw.echo.api.LocalAPIHandler.js index ac9ec18f7..da86b1fef 100644 --- a/modules/api/mw.echo.api.LocalAPIHandler.js +++ b/modules/api/mw.echo.api.LocalAPIHandler.js @@ -53,13 +53,18 @@ /** * @inheritdoc */ - mw.echo.api.LocalAPIHandler.prototype.markAllRead = function ( type ) { + mw.echo.api.LocalAPIHandler.prototype.markAllRead = function ( source, type ) { + var data; type = Array.isArray( type ) ? type : [ type ]; - - return this.api.postWithToken( 'csrf', { + data = { action: 'echomarkread', sections: type.join( '|' ) - } ) + }; + if ( !this.isSourceLocal( source ) ) { + data.wikis = source; + } + + return this.api.postWithToken( 'csrf', data ) .then( function ( result ) { return OO.getProp( result.query, 'echomarkread', type, 'rawcount' ) || 0; } ); @@ -68,11 +73,15 @@ /** * @inheritdoc */ - mw.echo.api.LocalAPIHandler.prototype.markItemsRead = function ( itemIdArray, isRead ) { + mw.echo.api.LocalAPIHandler.prototype.markItemsRead = function ( source, itemIdArray, isRead ) { var data = { action: 'echomarkread' }; + if ( !this.isSourceLocal( source ) ) { + data.wikis = source; + } + if ( isRead ) { data.list = itemIdArray.join( '|' ); } else {