mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-03 20:06:59 +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
|
* Mark all notifications as read
|
||||||
*
|
*
|
||||||
|
* @param {string} source Wiki name
|
||||||
* @param {string|string[]} type Notification type 'message', 'alert' or 'all'.
|
* @param {string|string[]} type Notification type 'message', 'alert' or 'all'.
|
||||||
* @return {jQuery.Promise} A promise that resolves when all notifications
|
* @return {jQuery.Promise} A promise that resolves when all notifications
|
||||||
* are marked as read.
|
* are marked as read.
|
||||||
|
@ -192,6 +193,7 @@
|
||||||
* Mark multiple notification items as read using specific IDs
|
* Mark multiple notification items as read using specific IDs
|
||||||
*
|
*
|
||||||
* @abstract
|
* @abstract
|
||||||
|
* @param {string} source Wiki name
|
||||||
* @param {string[]} itemIdArray An array of notification item IDs
|
* @param {string[]} itemIdArray An array of notification item IDs
|
||||||
* @param {boolean} [isRead] Item's new read state; true for marking the item
|
* @param {boolean} [isRead] Item's new read state; true for marking the item
|
||||||
* as read, false for marking the item as unread
|
* as read, false for marking the item as unread
|
||||||
|
|
|
@ -239,7 +239,8 @@
|
||||||
* for that type in the given source
|
* for that type in the given source
|
||||||
*/
|
*/
|
||||||
mw.echo.api.EchoApi.prototype.markItemsRead = function ( itemIds, source, isRead ) {
|
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
|
* for that type in the given source
|
||||||
*/
|
*/
|
||||||
mw.echo.api.EchoApi.prototype.markAllRead = function ( source, type ) {
|
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
|
* @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 ];
|
type = Array.isArray( type ) ? type : [ type ];
|
||||||
|
data = {
|
||||||
return this.api.postWithToken( 'csrf', {
|
|
||||||
action: 'echomarkread',
|
action: 'echomarkread',
|
||||||
sections: type.join( '|' )
|
sections: type.join( '|' )
|
||||||
} )
|
};
|
||||||
|
if ( !this.isSourceLocal( source ) ) {
|
||||||
|
data.wikis = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.api.postWithToken( 'csrf', data )
|
||||||
.then( function ( result ) {
|
.then( function ( result ) {
|
||||||
return OO.getProp( result.query, 'echomarkread', type, 'rawcount' ) || 0;
|
return OO.getProp( result.query, 'echomarkread', type, 'rawcount' ) || 0;
|
||||||
} );
|
} );
|
||||||
|
@ -68,11 +73,15 @@
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
mw.echo.api.LocalAPIHandler.prototype.markItemsRead = function ( itemIdArray, isRead ) {
|
mw.echo.api.LocalAPIHandler.prototype.markItemsRead = function ( source, itemIdArray, isRead ) {
|
||||||
var data = {
|
var data = {
|
||||||
action: 'echomarkread'
|
action: 'echomarkread'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ( !this.isSourceLocal( source ) ) {
|
||||||
|
data.wikis = source;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isRead ) {
|
if ( isRead ) {
|
||||||
data.list = itemIdArray.join( '|' );
|
data.list = itemIdArray.join( '|' );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue