Constructor
new mw.echo.dm.ModelManager(counter, [config])
#
A container that manages all models that are involved in creating the notification list. There are currently two types of models:
mw.echo.dm
.SortedList - This currently includes the local model or any model that has individual messages.mw.echo.dm
.CrossWikiNotificationItem - This is a model for the cross wiki notification, which acts as an item but itself contains a list.
All notification models that are managed by the manager must implement the following methods:
- getName - This should retrieve the model's name for the manager to fetch
- isGroup - This should be true for xwiki model and local bundles
- hasUnseen - This should iterate in the model's items and check whether there are any unseen notifications within them.
- getCount - Get a total count of available notifications currently in the model
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
counter |
mw.echo.dm.UnreadNotificationCounter | Unread counter |
|
config |
Object |
optional |
Configuration object |
- Mixes in:
- Source:
A container that manages all models that are involved in creating the notification list.
Methods
checkLocalUnreadTalk()
#
Check whether there are talk notifications, and emit an event in case there aren't any left.
- Source:
Fires:
Check whether there are talk notifications, and emit an event in case there aren't any left.
getAllNotificationCount() → {number}
#
Go over all the notification models and return the total number of available notifications.
- Source:
Returns:
A count of all notifications
- Type
- number
Go over all the notification models and return the total number of available notifications.
getAllNotificationModels() → {Object}
#
Get the notifications
- Source:
Returns:
Object of notification models and their symbolic names
- Type
- Object
getFiltersModel() → {mw.echo.dm.FiltersModel}
#
Get the filters model
- Source:
Returns:
Filters model
getLocalCounter() → {mw.echo.dm.UnreadNotificationCounter}
#
Get the local counter
- Source:
Returns:
Local counter
getLocalNotifications() → {Array.<mw.echo.dm.NotificationItem>}
#
Get all local notifications
- Source:
Returns:
all local notifications
- Type
- Array.<mw.echo.dm.NotificationItem>
getLocalUnread() → {Array.<mw.echo.dm.NotificationItem>}
#
Get local unread notifications
- Source:
Returns:
Local unread notifications
- Type
- Array.<mw.echo.dm.NotificationItem>
getModelsBySource([source]) → {Array.<string>}
#
Get all models that have a specific source
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string |
optional |
'local' | Given source |
- Source:
Returns:
All model IDs that use this source
- Type
- Array.<string>
getNotificationModel(modelName) → {mw.echo.dm.SortedList}
#
Get a notification model.
Parameters:
Name | Type | Description |
---|---|---|
modelName |
string | Unique model name |
- Source:
Returns:
Notifications model
getNotificationsBySource([source]) → {Array.<mw.echo.dm.NotificationItem>}
#
Get all notifications that come from a given source
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string |
optional |
'local' | Source name |
- Source:
Returns:
All notifications from that source
- Type
- Array.<mw.echo.dm.NotificationItem>
getPaginationModel() → {mw.echo.dm.PaginationModel}
#
Get the pagination model
- Source:
Returns:
Pagination model
getSeenTime([source]) → {string}
#
Get the system seen time
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string |
optional |
'local' | Seen time source |
- Source:
Returns:
Seen time, as a full UTC ISO 8601 timestamp
- Type
- string
getSeenTimeModel() → {mw.echo.dm.SeenTimeModel}
#
Get the SeenTime model
- Source:
Returns:
SeenTime model
getTypeString() → {string}
#
Get the model types string; 'message', 'alert', or 'all'
- Source:
Returns:
Model types
- Type
- string
getTypes() → {Array.<string>}
#
getUnreadCounter() → {mw.echo.dm.UnreadNotificationCounter}
#
Get the unread notification counter
- Source:
Returns:
Unread notification counter
hasLocalUnread() → {boolean}
#
Check if the local model has any unread notifications.
- Source:
Returns:
Local model has unread notifications.
- Type
- boolean
hasLocalUnreadTalk() → {boolean}
#
Check if the local model has any unread talk page notifications.
- Source:
Returns:
Local model has unread talk page notifications.
- Type
- boolean
hasUnseenInAnyModel() → {boolean}
#
Check if there are unseen notifications in any of the models
- Source:
Returns:
Local model has unseen notifications.
- Type
- boolean
hasUnseenInModel(modelId) → {boolean}
#
Check if a model has any unseen notifications.
Parameters:
Name | Type | Description |
---|---|---|
modelId |
string | Model ID |
- Source:
Returns:
The given model has unseen notifications.
- Type
- boolean
hasUnseenInSource([source]) → {boolean}
#
Check if a model has any unseen notifications.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string |
optional |
'local' | Model source |
- Source:
Returns:
The given models has unseen notifications.
- Type
- boolean
onModelDiscardItems(modelId)
#
Respond to a notification model discarding items.
Parameters:
Name | Type | Description |
---|---|---|
modelId |
string | Model name |
- Source:
onModelItemUpdate(modelName, item)
#
Respond to model update event
Parameters:
Name | Type | Description |
---|---|---|
modelName |
string | Model name |
item |
mw.echo.dm.NotificationItem | Notification item |
- Source:
Fires:
onSeenTimeUpdate(timestamp)
#
Respond to seen time change for a given source
Parameters:
Name | Type | Description |
---|---|---|
timestamp |
string | Seen time, as a full UTC ISO 8601 timestamp |
- Source:
Fires:
removeNotificationModel(modelName)
#
Remove a model from the manager
Parameters:
Name | Type | Description |
---|---|---|
modelName |
string | Symbolic name of the model |
- Source:
Fires:
resetNotificationModels()private
#
Reset all models
- Source:
setNotificationModels(modelDefinitions)
#
Set the models in the manager.
Parameters:
Name | Type | Description |
---|---|---|
modelDefinitions |
Object | An object defining the models
The format for the definition object is:
{
'modelId': { |
- Source:
Fires:
updateCurrentPageItemCount()
#
Update the current page item count based on available items
- Source:
Events
allTalkRead()
#
There are no more local talk page notifications
- Source:
discard(modelId)
#
A model has been permanently removed
Parameters:
Name | Type | Description |
---|---|---|
modelId |
string | Discard model id |
- Source:
localCountChange()
#
There was a change in the count of local unread notifications
- Source:
modelItemUpdate(modelId, item)
#
A specific item inside a notifications model has been updated
Parameters:
Name | Type | Description |
---|---|---|
modelId |
string | Model ID |
item |
mw.echo.dm.NotificationItem | Updated item |
- Source:
seen(source, timestamp)
#
All notifications in that source are seen
Parameters:
Name | Type | Description |
---|---|---|
source |
string | Source where seenTime was updated |
timestamp |
number | The new seen timestamp, as a full UTC ISO 8601 timestamp |
- Source:
update(Current)
#
The model has been rebuilt or has been updated
Parameters:
- Source: