mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
Merge "Use API proxying for markasread requests in the front end"
This commit is contained in:
commit
9fad958301
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue