Expand all

abstract mw.echo.api.APIHandler

Constructor

new mw.echo.api.APIHandler(api, [config])abstract #

Abstract notification API handler

Parameters:

Name Type Attributes Description
api mw.Api
config Object optional

Configuration object

Source:
Abstract notification API handler

Properties

fetchNotifications #

Fetch notifications from the API.

Source:
Fetch notifications from the API.

fetchUnreadCount #

Query the API for unread count of the notifications in this model

Source:
Query the API for unread count of the notifications in this model

markAllRead #

Mark all notifications as read

Source:
Mark all notifications as read

markItemsReadabstract #

Mark multiple notification items as read using specific IDs

Source:
Mark multiple notification items as read using specific IDs

updateSeenTime #

Update the seen timestamp

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.

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.

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

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.

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

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

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

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

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

Source:

Returns:

Promise that is resolved when the action is complete

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