Handle the missing 'all' type as specified in the doc

The text for 'type' in the documentation of the parent describes the
notification type can be 'all', following 'message' and 'alert'. That is
actually used, for instance inside of
mw.echo.Controller.markLocalNotificationsRead() function. The gap
between doc and implementation results in bugs. This resolves the gap.

Bug: T270879
Change-Id: I546aa42e927a05a5426db90153901ae632b97e36
This commit is contained in:
lens0021 2022-04-20 21:57:12 +09:00
parent 1a44500829
commit 5943b13b5b
No known key found for this signature in database
GPG key ID: 85166D2A340F5595

View file

@ -55,12 +55,18 @@
* @inheritdoc
*/
mw.echo.api.LocalAPIHandler.prototype.markAllRead = function ( source, type ) {
var data;
type = Array.isArray( type ) ? type : [ type ];
data = {
action: 'echomarkread',
sections: type.join( '|' )
var data = {
action: 'echomarkread'
};
type = Array.isArray( type ) ? type : [ type ];
if ( type.indexOf( 'all' ) !== -1 ) {
// As specified in the documentation of the parent function, the type parameter can be
// 'all'. We especially handle that case here to match the PHP API. Note: Other values
// of the array will be ignored.
data.all = true;
} else {
data.sections = type.join( '|' );
}
if ( !this.isSourceLocal( source ) ) {
data.wikis = source;
}