Class: Notifications

notifications~Notifications

module:notifications.notifications implementation.

It also emits the named events downloaded, ignored-category-added and ignored-category-removed built with EventEmitter

Members

(private) _downloader :module:downloader.Downloader

The object providing actual downloading functionality.

Type:
Source:

(private) _localNotifications :Set.<Object>

Local notifications added via addNotification().

Type:
  • Set.<Object>
Source:

(private) _showListeners :Set.<function()>

Listeners for notifications to be shown.

Type:
  • Set.<function()>
Source:

(private) _started

Whether the fetching of notifications has been started.

Source:

ignored :boolean

Whether all ignorable notifications should be ignored.

Type:
  • boolean
Source:

locale :string

The locale for the localization of notification texts.

Type:
  • string
Default Value:
Source:

(nullable) numBlocked :number

The number to consider when performing the blockedTotalMin and blockedTotalMax target checks.

This property needs to be initialized at startup and updated whenever a blocking filter matches. If set to null (default), notifications using these target checks are ignored.

If the deprecated preferences Prefs.show_statsinpopup and Prefs.blocked_total exist they take precedence over this property.

Type:
  • number
Source:

Methods

(generator, private) _getDownloadables() → {module:downloader.Downloadable}

Yields a Downloadable instance for the notifications download.

Source:
Yields:
Type
module:downloader.Downloadable

(private) _getNextToShow() → (nullable) {object}

Determines which notification is to be shown next.

Source:
Returns:

The notification to be shown, or null if there is none.

Type
object

(private) _getNotifications() → {Array.<Object>}

Returns all local and remote notifications.

Source:
Returns:

All local and remote notifications.

Type
Array.<Object>

addNotification(notification)

Adds a local notification.

Parameters:
Name Type Description
notification Object

The notification to add.

Source:

addShowListener(listener)

Adds a listener for notifications to be shown.

Parameters:
Name Type Description
listener function

Listener to be invoked when a notification is to be shown.

Source:

getDownloadCount() → {number}

Returns the number of times the notifications data have been downloaded.

Source:
Returns:
Type
number

getIgnoredCategories() → {Array.<string>}

Returns the list of ignored categories.

Source:
Returns:
Type
Array.<string>

getLocalizedTexts(notification) → {Object}

Localizes the texts of the given notification based on the locale.

Parameters:
Name Type Description
notification Object

The notification.

Source:
Returns:

The localized texts.

Type
Object

markAsShown(id)

Marks a notification as shown.

Parameters:
Name Type Description
id string

The ID of the notification to be marked as shown.

Source:

removeNotification(notification)

Removes an existing local notification.

Parameters:
Name Type Description
notification Object

The notification to remove.

Source:

removeShowListener(listener)

Removes the supplied listener.

Parameters:
Name Type Description
listener function

Listener that was added via addShowListener().

Source:

shouldIgnoreNotifications() → {boolean}

Returns whether user preferences indicate that notifications should be ignored.

Source:
Returns:
Type
boolean

showNext()

Invokes the listeners added via addShowListener() with the next notification to be shown.

This method should be called whenever a page loads.

Source:

showNotification(notification, optionsopt)

Shows a notification once.

Parameters:
Name Type Attributes Description
notification Object

The notification to show.

options Object <optional>
Properties
Name Type Attributes Default Description
ignorable boolean <optional>
false

If true, user preference will be considered to determine whether notification should be shown.

Source:

start()

Starts fetching notifications.

No notifications are fetched until this function has been called at least once.

Source:

stop()

Stops fetching notifications.

Source:

toggleIgnoreCategory(category, forceValueopt)

Toggles whether notifications of a specific category should be ignored.

Parameters:
Name Type Attributes Description
category string

The notification category identifier.

forceValue boolean <optional>

Whether to force the specified value.

Source: