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:
Methods
estimateChange(delta)
#
Report an estimated change to this counter
Parameters:
Name | Type | Description |
---|---|---|
delta |
number |
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 |
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
Returns:
current count
- Type
- number
setCount(count, isEstimation)
#
Set the current count
Parameters:
Name | Type | Description |
---|---|---|
count |
number | |
isEstimation |
boolean | Whether this number is estimated or accurate |
Fires:
setSource(source)
#
Set the source for this counter
Parameters:
Name | Type | Description |
---|---|---|
source |
string | Source name |
update() → {jQuery.Promise}
#
Request that this counter update itself from the API
Returns:
Promise that is resolved when the actual unread count is fetched, with the actual unread notification count.
- Type
- jQuery.Promise
Events
countChange(count)
#
The number of unread notification represented by this counter has changed.
Parameters:
Name | Type | Description |
---|---|---|
count |
number | Notification count |