moderator-toolbox-nxg-for-reddit / modules/subredditnotes/helpers

modules/subredditnotes/helpers

Functions

filterAndSortNotes()

filterAndSortNotes(notes, __namedParameters): SubredditNoteMeta[]

Defined in: extension/data/modules/subredditnotes/helpers.ts:52

Returns a filtered and sorted subset of notes according to the given criteria.

Parameters

notes

SubredditNoteMeta[]

Full note list to filter.

__namedParameters
selectedAuthors?

string[] = []

When non-empty, only notes whose author is in this list are shown.

selectedTags?

string[] = []

When non-empty, only notes that contain ALL of these tags are shown.

showArchived

boolean

sort

SubredditNoteSort

Returns

SubredditNoteMeta[]


getAllAuthors()

getAllAuthors(notes): string[]

Defined in: extension/data/modules/subredditnotes/helpers.ts:119

Collects all unique authors from the given notes, sorted alphabetically.

Parameters

notes

SubredditNoteMeta[]

Notes to scan.

Returns

string[]


getAllTags()

getAllTags(notes): object[]

Defined in: extension/data/modules/subredditnotes/helpers.ts:103

Collects all unique tags from the given notes with occurrence counts, sorted by count descending then alphabetically.

Parameters

notes

SubredditNoteMeta[]

Notes to scan (pass already-filtered notes to respect archive visibility).

Returns

object[]


makeTimestampUserSlug()

makeTimestampUserSlug(timestamp, user, existingSlugs): string

Defined in: extension/data/modules/subredditnotes/helpers.ts:37

Generates a slug from a unix timestamp and user, appending a numeric suffix if the slug is already taken.

Parameters

timestamp

number

user

string

existingSlugs

Iterable<string>

Returns

string


makeUniqueSlug()

makeUniqueSlug(title, existingSlugs): string

Defined in: extension/data/modules/subredditnotes/helpers.ts:26

Derives a URL-safe slug from a note title, appending a numeric suffix if the slug is already taken or reserved.

Parameters

title

string

existingSlugs

Iterable<string>

Returns

string


parseTags()

parseTags(value): string[]

Defined in: extension/data/modules/subredditnotes/helpers.ts:137

Parses a comma-separated tag string into a deduplicated array of trimmed tags.

Parameters

value

string

Returns

string[]


shouldWarnUnsaved()

shouldWarnUnsaved(savedValue, editorValue, saving): boolean

Defined in: extension/data/modules/subredditnotes/helpers.ts:130

Returns true when there are unsaved changes that should warn before navigation.

Parameters

savedValue

string

editorValue

string

saving

boolean

Returns

boolean