moderator-toolbox-nxg-for-reddit / modules/usernotes/components/UserNotesManagerOverlay.helpers

modules/usernotes/components/UserNotesManagerOverlay.helpers

Functions

createPrunePreview()

createPrunePreview(users, options, colors, now?, sampleSize?): PrunePreview

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:513

Performs a dry-run prune based on age and type rules, returning a preview of what would be removed. Account-status checks (deleted/suspended/inactive) are not performed here; they run during the real prune.

Parameters

users

Record<string, UsernotesUser>

The users (keyed by name) to evaluate for pruning.

options

PruneOptions

Prune rules (age threshold, note-type filters).

colors

UserNoteColor[]

The note-color definitions used to resolve note types.

now?

number = ...

Current timestamp in ms; injectable for testing.

sampleSize?

number = 20

Maximum number of matching note rows to include in the preview.

Returns

PrunePreview


estimateUsernotesStorageBytes()

estimateUsernotesStorageBytes(users): number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:180

Estimates the compressed wiki storage size that the given users list would occupy. Uses the same deflate + JSON encoding path as the actual save operation.

Parameters

users

UsernotesUser[]

Returns

number


filterUsers()

filterUsers(users, filters): ManagerUser[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:383

Filters and maps users based on the active browse-view filters. Users whose notes don’t match any filter criterion are excluded entirely.

Parameters

users

UsernotesUser[]

filters

UserNotesManagerFilters

Returns

ManagerUser[]


getKindColor()

getKindColor(colors, key): string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:236

Returns the hex color string for a note type key.

Parameters

colors

UserNoteColor[]

key

string | undefined

Returns

string

The configured color, or an empty string when the key is absent/empty.


getKindLabel()

getKindLabel(colors, key): string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:227

Returns the display label for a note type key.

Parameters

colors

UserNoteColor[]

key

string | undefined

Returns

string

The configured label, or 'No type' when the key is absent/empty.


getNoteStats()

getNoteStats(users, colors): NoteStats

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:242

Computes aggregate note statistics (counts, timestamps, per-type breakdown) for a set of users.

Parameters

users

UsernotesUser[]

colors

UserNoteColor[]

Returns

NoteStats


getUserNotesStatistics()

getUserNotesStatistics(users, colors, now?): UserNotesStatistics

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:288

Computes the full statistics object shown in the Statistics tab of the manager overlay.

Parameters

users

UsernotesUser[]

The users (with their notes) to aggregate.

colors

UserNoteColor[]

The note-color definitions used to bucket notes by type.

now?

number = ...

Current timestamp in ms; injectable for testing.

Returns

UserNotesStatistics


normalizeKindKey()

normalizeKindKey(key): string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:208

Returns the storage key used for a note type, substituting a sentinel for undefined/empty. Ensures notes with no type have a consistent key for grouping and filtering.

Parameters

key

string | undefined

Returns

string


shouldPruneNoteByArchived()

shouldPruneNoteByArchived(note, options): boolean

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:497

Decides whether a note is eligible for pruning given the archived-handling mode. Shared between the dry-run preview and the real prune executor so the two never diverge.

Parameters

note

UserNoteEntry

The note to test.

options

PruneOptions

Prune rules; only pruneArchived is consulted here.

Returns

boolean


sortUsers()

sortUsers(users, sortKey, direction, colors): ManagerUser[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:440

Sorts a list of manager users by the given key and direction, also sorting each user’s notes internally.

Parameters

users

ManagerUser[]

The users to sort.

sortKey

UserNotesManagerSortKey

The column to sort by.

direction

SortDirection

Sort direction.

colors

UserNoteColor[]

Used to resolve kind labels for kind-based sorting.

Returns

ManagerUser[]


statLabel()

statLabel(count, singular, plural?): string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:219

Formats a count with a localized number and a singular/plural noun, e.g. statLabel(1, 'note') -> "1 note", statLabel(3, 'note') -> "3 notes".

Parameters

count

number

The quantity to render.

singular

string

The noun to use when count is 1.

plural?

string = ...

The noun to use otherwise; defaults to singular + 's'.

Returns

string

Interfaces

ManagerUser

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:47

A usernote user augmented with the unfiltered original notes for display totals.

Extends

Properties

name

name: string

Defined in: extension/data/util/wiki/schemas/usernotes/schema.ts:123

Inherited from

UsernotesUser.name

nextIndex?

optional nextIndex?: number

Defined in: extension/data/util/wiki/schemas/usernotes/schema.ts:129

The next note index to assign for this user. Persisted (not derived) so indexes are never reused, even after notes are deleted or pruned.

Inherited from

UsernotesUser.nextIndex

notes

notes: UserNoteEntry[]

Defined in: extension/data/util/wiki/schemas/usernotes/schema.ts:124

Inherited from

UsernotesUser.notes

originalNotes?

optional originalNotes?: UserNoteEntry[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:49

The full unfiltered note list before search filters were applied.


NoteStats

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:53

Aggregate note statistics for a set of users.

Properties

emptyUserCount

emptyUserCount: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:57

Number of users who have zero notes (usually after pruning).

newestNoteTime

newestNoteTime: number | null

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:60

noteCount

noteCount: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:58

oldestNoteTime

oldestNoteTime: number | null

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:59

typeCounts

typeCounts: object[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:62

Per-type note counts sorted by the subreddit’s configured type order.

color

color: string

count

count: number

key

key: string

label

label: string

userCount

userCount: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:55

Number of users who have at least one note.


PrunePreview

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:74

Result of a dry-run prune operation for preview display.

Properties

matched

matched: Map<string, Set<number>>

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:90

The stable indexes of every matched note, keyed by username - the single source of truth for “what would be pruned”. The real prune seeds its match set from this (then adds account-status matches) and drives both delete and archive from it, instead of re-deriving the set.

prunedNotes

prunedNotes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:77

prunedUsers

prunedUsers: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:79

Users that would lose all their notes (their records are retained).

sampleRows

sampleRows: PrunePreviewRow[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:83

Up to sampleSize matching rows for display in the preview table.

totalNotes

totalNotes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:80

totalUsers

totalUsers: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:81

users

users: Record<string, UsernotesUser>

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:76

The remaining users after the prune rules have been applied.


PrunePreviewRow

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:66

A single row in the prune preview sample list.

Properties

kindLabel

kindLabel: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:70

Human-readable label for the note’s kind.

note

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:68

user

user: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:67


UserNotesManagerFilters

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:20

Active filter values for the manager browse view.

Extended by

Properties

archived?

optional archived?: ArchivedMode

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:36

Controls which archived notes are visible, sharing the prune executor’s ArchivedMode vocabulary:

  • 'exclude' (default): archived notes are hidden.

  • 'include': archived notes are shown alongside active notes.

  • 'only': only archived notes are shown.

contentText

contentText: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:24

Note text substring filter.

kind

kind: string[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:26

Note kind key filter: empty array shows all kinds, otherwise only matching kinds are shown.

moderator

moderator: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:28

Moderator username filter, or 'all' to show all mods.

userText

userText: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:22

Username substring filter.


UserNotesManagerPreferences

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:40

Persisted preferences for the manager browse view, extending the active filters.

Extends

Properties

archived?

optional archived?: ArchivedMode

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:36

Controls which archived notes are visible, sharing the prune executor’s ArchivedMode vocabulary:

  • 'exclude' (default): archived notes are hidden.

  • 'include': archived notes are shown alongside active notes.

  • 'only': only archived notes are shown.

Inherited from

UserNotesManagerFilters.archived

contentText

contentText: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:24

Note text substring filter.

Inherited from

UserNotesManagerFilters.contentText

kind

kind: string[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:26

Note kind key filter: empty array shows all kinds, otherwise only matching kinds are shown.

Inherited from

UserNotesManagerFilters.kind

moderator

moderator: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:28

Moderator username filter, or 'all' to show all mods.

Inherited from

UserNotesManagerFilters.moderator

pageSize

pageSize: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:43

sortDirection

sortDirection: SortDirection

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:42

sortKey

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:41

userText

userText: string

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:22

Username substring filter.

Inherited from

UserNotesManagerFilters.userText


UserNotesStatistics

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:94

Comprehensive statistics for the Statistics tab of the usernotes manager.

Properties

activeNotes

activeNotes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:111

Number of non-archived (visible) notes.

ageBuckets

ageBuckets: object[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:120

Note counts grouped into age ranges.

count

count: number

label

label: string

archivedNotes

archivedNotes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:109

Number of archived notes (hidden by default but kept).

averageNoteLength

averageNoteLength: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:106

averageNotesPerUser

averageNotesPerUser: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:99

emptyUsers

emptyUsers: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:97

longestNoteLength

longestNoteLength: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:107

maxNotesOnUser

maxNotesOnUser: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:100

moderatorCounts

moderatorCounts: object[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:123

Top 10 moderators by note count.

count

count: number

name

name: string

newestNoteTime

newestNoteTime: number | null

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:118

notesWithoutTypes

notesWithoutTypes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:104

notesWithTypes

notesWithTypes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:103

oldestNoteTime

oldestNoteTime: number | null

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:117

storageBytesRemaining

storageBytesRemaining: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:114

storageBytesUsed

storageBytesUsed: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:113

Estimated compressed wiki storage used, in bytes.

storagePercentUsed

storagePercentUsed: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:116

Percentage of the wiki storage limit consumed (0-100).

topUsers

topUsers: object[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:125

Top 10 users by note count.

count

count: number

name

name: string

newestNoteTime

newestNoteTime: number | null

totalNotes

totalNotes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:98

totalUsers

totalUsers: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:95

typeCounts

typeCounts: object[]

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:121

color

color: string

count

count: number

key

key: string

label

label: string

uniqueModerators

uniqueModerators: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:105

usersWithNotes

usersWithNotes: number

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:96

Type Aliases

SortDirection

SortDirection = "asc" | "desc"

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:17

Sort order for the manager browse table.


UserNotesManagerSortKey

UserNotesManagerSortKey = "username" | "date" | "kind" | "noteCount" | "moderator"

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:15

Column by which the manager browse table can be sorted.


UsernotesStorageInfo

UsernotesStorageInfo = { mode: "legacy"; totalBytes: number; } | { largestShardBytes: number; legacyCompatBytes?: number; mode: "sharded"; shardCount: number; totalBytes: number; }

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:138

Actual wiki storage usage for the manager’s statistics tab. legacy means the single legacy usernotes page, bound by Reddit’s 1MB allowance for that path; sharded means the NXG layout, where capacity is effectively unlimited because pages split automatically near the per-page limit.

Union Members

Type Literal

{ mode: "legacy"; totalBytes: number; }


Type Literal

{ largestShardBytes: number; legacyCompatBytes?: number; mode: "sharded"; shardCount: number; totalBytes: number; }

largestShardBytes

largestShardBytes: number

legacyCompatBytes?

optional legacyCompatBytes?: number

Size of the 6.x legacy mirror page, present when compatibility writes are enabled.

mode

mode: "sharded"

shardCount

shardCount: number

totalBytes

totalBytes: number

Variables

usernotesWikiMaxBytes

const usernotesWikiMaxBytes: 1048576 = 1_048_576

Defined in: extension/data/modules/usernotes/components/UserNotesManagerOverlay.helpers.ts:129

Maximum usernotes wiki page size in bytes (1 MB Reddit limit).