moderator-toolbox-nxg-for-reddit / modules/notifier/poll

modules/notifier/poll

Functions

createNotifierHandlers()

createNotifierHandlers(options, module): NotifierHandlers

Defined in: extension/data/modules/notifier/poll.ts:171

Creates polling and event-handling functions for the Notifier module.

Parameters

options

ModbarCounterOptions

Runtime configuration (intervals, subreddits, initial counts, etc.).

module

NotifierStorage

Storage adapter for persisting counts and timestamps between poll cycles.

Returns

NotifierHandlers


toModmailCategoryCount()

toModmailCategoryCount(value): Record<string, number>

Defined in: extension/data/modules/notifier/poll.ts:40

Coerces an unknown stored value to Record<string, number> for modmail category counts. Returns an empty object if the value is null, not an object, or an array.

Parameters

value

unknown

Returns

Record<string, number>

Interfaces

ModbarCounterOptions

Defined in: extension/data/modules/notifier/poll.ts:123

Runtime options passed to createNotifierHandlers.

Properties

checkIntervalMillis

checkIntervalMillis: number

Defined in: extension/data/modules/notifier/poll.ts:144

Polling interval in milliseconds.

consolidatedMessages

consolidatedMessages: boolean

Defined in: extension/data/modules/notifier/poll.ts:136

When true, multiple new items are combined into a single notification instead of one per item.

modmailCategoryCount

modmailCategoryCount: Record<string, number>

Defined in: extension/data/modules/notifier/poll.ts:152

Per-category unread modmail counts.

modmailCount

modmailCount: number

Defined in: extension/data/modules/notifier/poll.ts:150

Last known total unread modmail count.

modNotifications

modNotifications: boolean

Defined in: extension/data/modules/notifier/poll.ts:132

Whether to fire browser notifications for new modqueue items.

modqueueCount

modqueueCount: number

Defined in: extension/data/modules/notifier/poll.ts:146

Last known modqueue count, used to detect increases.

modSubreddits

modSubreddits: string

Defined in: extension/data/modules/notifier/poll.ts:138

Multireddit string for the modqueue counter (e.g. "mod").

showNotifications

showNotifications: boolean

Defined in: extension/data/modules/notifier/poll.ts:130

Master switch for notifications. When false, no notification is fired for any queue, but the counters still poll and update. Gating the notification() calls covers both delivery modes, since the native-vs-in-page choice is made inside that helper via the nativeNotifications setting.

unmoderatedCount

unmoderatedCount: number

Defined in: extension/data/modules/notifier/poll.ts:148

Last known unmoderated count, used to detect increases.

unmoderatedNotifications

unmoderatedNotifications: boolean

Defined in: extension/data/modules/notifier/poll.ts:134

Whether to fire browser notifications for new unmoderated items.

unmoderatedOn

unmoderatedOn: boolean

Defined in: extension/data/modules/notifier/poll.ts:142

Whether the unmoderated counter is visible in the modbar.

unmoderatedSubreddits

unmoderatedSubreddits: string

Defined in: extension/data/modules/notifier/poll.ts:140

Multireddit string for the unmoderated counter.


NotifierHandlers

Defined in: extension/data/modules/notifier/poll.ts:156

Callbacks returned by createNotifierHandlers.

Properties

getmessages

getmessages: () => Promise<void>

Defined in: extension/data/modules/notifier/poll.ts:158

Checks for new modqueue/modmail items and updates counters; throttled by the check interval.

Returns

Promise<void>

handleCounterUpdate

handleCounterUpdate: (event) => void

Defined in: extension/data/modules/notifier/poll.ts:163

Handles a TB_UPDATE_COUNTERS event dispatched from the background script. If the event has no detail, forces a fresh API fetch; otherwise syncs counters from the payload.

Parameters
event

CustomEvent

Returns

void


NotifierStorage

Defined in: extension/data/modules/notifier/poll.ts:23

Minimal storage interface required by createNotifierHandlers. Typed against NotifierSettings so only valid setting keys can be read or written. Module<NotifierSettings> satisfies this interface structurally.

Methods

get()

get<K>(key): Promise<NotifierSettings[K]>

Defined in: extension/data/modules/notifier/poll.ts:24

Type Parameters
K

K extends "modSubreddits" | "unmoderatedSubreddits" | "showNotifications" | "consolidatedMessages" | "modNotifications" | "unmoderatedNotifications" | "checkInterval" | "modqueueCount" | "unmoderatedCount" | "modmailCount" | "modmailCategoryCount" | "lastChecked" | "lastSeenUnmoderated" | "modqueuePushed"

Parameters
key

K

Returns

Promise<NotifierSettings[K]>

set()

set<K>(key, value): Promise<unknown>

Defined in: extension/data/modules/notifier/poll.ts:25

Type Parameters
K

K extends "modSubreddits" | "unmoderatedSubreddits" | "showNotifications" | "consolidatedMessages" | "modNotifications" | "unmoderatedNotifications" | "checkInterval" | "modqueueCount" | "unmoderatedCount" | "modmailCount" | "modmailCategoryCount" | "lastChecked" | "lastSeenUnmoderated" | "modqueuePushed"

Parameters
key

K

value

NotifierSettings[K]

Returns

Promise<unknown>