Expand all

mw.echo.dm.UnreadNotificationCounter

Constructor

new mw.echo.dm.UnreadNotificationCounter(api, type, max, config) #

Echo notification UnreadNotificationCounter model

Parameters:

Name Type Description
api Object

An instance of EchoAPI.

type string

The notification type 'message', 'alert', or 'all'.

max number

Maximum number supported. Above this number there is no precision, we only know it is 'more than max'.

config Object

Configuration object

Mixes in:
Source:
Echo notification UnreadNotificationCounter model

Methods

estimateChange(delta) #

Report an estimated change to this counter

Parameters:

Name Type Description
delta number
Source:
Report an estimated change to this counter

getCappedNotificationCount(count) → {number} #

Normalizes for a capped count in case the requested count is higher than the cap.

This is the client-side version of NotificationController::getCappedNotificationCount.

Parameters:

Name Type Description
count number

Count before cap is applied

Source:

Returns:

Count with cap applied

Type
number

Normalizes for a capped count in case the requested count is higher than the cap.

getCount() → {number} #

Get the current count

Source:

Returns:

current count

Type
number
Get the current count

setCount(count, isEstimation) #

Set the current count

Parameters:

Name Type Description
count number
isEstimation boolean

Whether this number is estimated or accurate

Source:

Fires:

Set the current count

setSource(source) #

Set the source for this counter

Parameters:

Name Type Description
source string

Source name

Source:
Set the source for this counter

update() → {jQuery.Promise} #

Request that this counter update itself from the API

Source:

Returns:

Promise that is resolved when the actual unread count is fetched, with the actual unread notification count.

Type
jQuery.Promise
Request that this counter update itself from the API

Events

countChange(count) #

The number of unread notification represented by this counter has changed.

Parameters:

Name Type Description
count number

Notification count

Source:
The number of unread notification represented by this counter has changed.