Constructor
new mw.echo.api.APIHandler(api, [config])abstract
#
Children
Abstract notification API handler
Parameters:
- Source:
Properties
fetchNotifications
#
Fetch notifications from the API.
- Source:
fetchUnreadCount
#
Query the API for unread count of the notifications in this model
- Source:
markAllRead
#
Mark all notifications as read
- Source:
markItemsReadabstract
#
Mark multiple notification items as read using specific IDs
- Source:
updateSeenTime
#
Update the seen timestamp
- Source:
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
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
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
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
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
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:
|
- Source:
Returns:
Promise that is resolved when the action is complete
- Type
- jQuery.Promise