Expand all

mw.echo.api.LocalAPIHandler

Extends

Constructor

new mw.echo.api.LocalAPIHandler([config]) #

Parameters:

Name Type Attributes Description
config Object optional

Configuration object

Source:
Notification API handler

Properties

fetchNotifications #

Fetch notifications from the API.

Overrides:
Source:
Fetch notifications from the API.

markAllRead #

Mark all notifications as read

Overrides:
Source:
Mark all notifications as read

markItemsRead #

Mark multiple notification items as read using specific IDs

Overrides:
Source:
Mark multiple notification items as read using specific IDs

updateSeenTime #

Update the seen timestamp

Overrides:
Source:
Update the seen timestamp

Methods

createNewFetchNotificationPromise(type, [sources], [overrideParams]) → {jQuery.Promise} #

Create a new fetchNotifications promise that queries the API and overrides the cached promise.

Parameters:

Name Type Attributes Description
type string

Notification type

sources Array.<string> optional

An array of sources to query

overrideParams Object optional

An object defining parameters to override in the API fetching call.

Inherited from:
Source:

Returns:

Promise that is resolved when notifications are fetched from the API.

Type
jQuery.Promise

Create a new fetchNotifications promise that queries the API and overrides the cached promise.

fetchUnreadCount(type, [ignoreCrossWiki]) → {jQuery.Promise} #

Fetch the number of unread notifications.

Parameters:

Name Type Attributes Description
type string

Notification type, 'alert', 'message' or 'all'

ignoreCrossWiki boolean optional

Ignore cross-wiki notifications when fetching the count. If set to false (by default) it counts notifications across all wikis.

Overrides:
Source:

Returns:

Promise which resolves with the unread count

Type
jQuery.Promise
Fetch the number of unread notifications.

fetchUnreadNotificationPages([sources]) → {jQuery.Promise} #

Fetch all pages with unread notifications in them per wiki

Parameters:

Name Type Attributes Default Description
sources string | Array.<string> optional
*

Requested sources. If not given or if a '*' is given, all available sources will be queried

Inherited from:
Source:

Returns:

Promise that is resolved with an object of pages with the number of unread notifications per wiki

Type
jQuery.Promise
Fetch all pages with unread notifications in them per wiki

getFetchNotificationPromise(type, [sources], [overrideParams]) → {jQuery.Promise} #

Return the fetch notifications promise

Parameters:

Name Type Attributes Description
type string

Notification type, 'alert', 'message' or 'all'

sources string | Array.<string> optional

A name of a source or an array of sources to query

overrideParams Object optional

An object defining parameters to override in the API fetching call.

Inherited from:
Source:

Returns:

Promise that is resolved when notifications are fetched from the API.

Type
jQuery.Promise
Return the fetch notifications promise

getTypeParams(type) → {Object} #

Get the extra parameters for fetching notifications for a given notification type.

Parameters:

Name Type Description
type string

Notification type

Overrides:
Source:

Returns:

Extra API parameters for fetch notifications

Type
Object

Get the extra parameters for fetching notifications for a given notification type.

isFetchingErrorState(type, sources) → {boolean} #

Check whether the model has an API error state flagged

Parameters:

Name Type Description
type string

Notification type, 'alert', 'message' or 'all'

sources string | Array.<string>

Source names

Inherited from:
Source:

Returns:

The model is in API error state

Type
boolean
Check whether the model has an API error state flagged

isSourceLocal(sources) → {boolean} #

Check if the given source is local

Parameters:

Name Type Description
sources string | Array.<string>

Source names

Inherited from:
Source:

Returns:

Source is local

Type
boolean
Check if the given source is local

markItemRead(itemId, [isRead]) → {jQuery.Promise} #

Update the read status of a notification item in the API

Parameters:

Name Type Attributes Description
itemId string

Item id

isRead boolean optional

Item's new read state; true for marking the item as read, false for marking the item as unread

Inherited from:
Source:

Returns:

A promise that resolves when the notifications are marked as read.

Type
jQuery.Promise
Update the read status of a notification item in the API

queryAPI(data) → {jQuery.Promise} #

Send a general query to the API. This is mostly for dynamic actions where other extensions may set up API actions that are unique and unanticipated.

Parameters:

Name Type Description
data Object

Data object about the operation.

Properties:
Name Type Attributes Default Description
tokenType string optional
csrf

Token type, 'csrf', 'watch', etc

params Object optional

Parameters to pass to the API call

Inherited from:
Source:

Returns:

Promise that is resolved when the action is complete

Type
jQuery.Promise
Send a general query to the API.