Expand all

mw.echo.dm.ModelManager

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
Get the notifications

getFiltersModel() → {mw.echo.dm.FiltersModel} #

Get the filters model

Source:

Returns:

Filters model

Type
mw.echo.dm.FiltersModel
Get the filters model

getLocalCounter() → {mw.echo.dm.UnreadNotificationCounter} #

Get the local counter

Source:

Returns:

Local counter

Type
mw.echo.dm.UnreadNotificationCounter
Get the local counter

getLocalNotifications() → {Array.<mw.echo.dm.NotificationItem>} #

Get all local notifications

Source:

Returns:

all local notifications

Type
Array.<mw.echo.dm.NotificationItem>
Get all local notifications

getLocalUnread() → {Array.<mw.echo.dm.NotificationItem>} #

Get local unread notifications

Source:

Returns:

Local unread notifications

Type
Array.<mw.echo.dm.NotificationItem>
Get local unread notifications

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>
Get all models that have a specific source

getNotificationModel(modelName) → {mw.echo.dm.SortedList} #

Get a notification model.

Parameters:

Name Type Description
modelName string

Unique model name

Source:

Returns:

Notifications model

Type
mw.echo.dm.SortedList
Get a notification 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>
Get all notifications that come from a given source

getPaginationModel() → {mw.echo.dm.PaginationModel} #

Get the pagination model

Source:

Returns:

Pagination model

Type
mw.echo.dm.PaginationModel
Get the 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
Get the system seen time

getSeenTimeModel() → {mw.echo.dm.SeenTimeModel} #

Get the SeenTime model

Source:

Returns:

SeenTime model

Type
mw.echo.dm.SeenTimeModel
Get the SeenTime model

getTypeString() → {string} #

Get the model types string; 'message', 'alert', or 'all'

Source:

Returns:

Model types

Type
string
Get the model types string; 'message', 'alert', or 'all'

getTypes() → {Array.<string>} #

Get the array of model types

Source:

Returns:

Model types

Type
Array.<string>
Get the array of model types

getUnreadCounter() → {mw.echo.dm.UnreadNotificationCounter} #

Get the unread notification counter

Source:

Returns:

Unread notification counter

Type
mw.echo.dm.UnreadNotificationCounter
Get the unread notification counter

hasLocalUnread() → {boolean} #

Check if the local model has any unread notifications.

Source:

Returns:

Local model has unread notifications.

Type
boolean
Check if the local model has any unread notifications.

hasLocalUnreadTalk() → {boolean} #

Check if the local model has any unread talk page notifications.

Source:

Returns:

Local model has unread talk page notifications.

Type
boolean
Check if the local model has any unread talk page notifications.

hasUnseenInAnyModel() → {boolean} #

Check if there are unseen notifications in any of the models

Source:

Returns:

Local model has unseen notifications.

Type
boolean
Check if there are unseen notifications in any of the models

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
Check if a model has any unseen notifications.

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
Check if a model has any unseen notifications.

onModelDiscardItems(modelId) #

Respond to a notification model discarding items.

Parameters:

Name Type Description
modelId string

Model name

Source:
Respond to a notification model discarding items.

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:

Respond to model update event

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:

Respond to seen time change for a given source

removeNotificationModel(modelName) #

Remove a model from the manager

Parameters:

Name Type Description
modelName string

Symbolic name of the model

Source:

Fires:

Remove a model from the manager

resetNotificationModels()private #

Reset all models

Source:
Reset all models

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': {mw.echo.dm.SortedList}, ... }

Source:

Fires:

Set the models in the manager.

updateCurrentPageItemCount() #

Update the current page item count based on available items

Source:
Update the current page item count based on available items

Events

allTalkRead() #

There are no more local talk page notifications

Source:
There are no more local talk page notifications

discard(modelId) #

A model has been permanently removed

Parameters:

Name Type Description
modelId string

Discard model id

Source:
A model has been permanently removed

localCountChange() #

There was a change in the count of local unread notifications

Source:
There was a change in the count of local unread notifications

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:
A specific item inside a notifications model has been updated

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:
All notifications in that source are seen

update(Current) #

The model has been rebuilt or has been updated

Parameters:

Name Type Description
Current Array.<Object>

available notifications

Source:
The model has been rebuilt or has been updated