moderator-toolbox-nxg-for-reddit / util/wiki/wikiPaths

util/wiki/wikiPaths

Functions

compatMirrorEnabled()

compatMirrorEnabled(layout): boolean

Defined in: extension/data/util/wiki/wikiPaths.ts:292

Returns true when the layout maintains the legacy 6.x mirror: writes fan out to the legacy paths second, and reads reconcile 6.x edits found there back into the canonical NXG data. Always false for legacyFallback subs (which write legacy only) and for subs with missing NXG pages.

Parameters

layout

WikiLayout

Returns

boolean


getNotePagePrefix()

getNotePagePrefix(subreddit): Promise<string>

Defined in: extension/data/util/wiki/wikiPaths.ts:332

Returns the note page prefix for the subreddit’s current canonical layout, used to derive slugs when scanning wiki page listings.

Parameters

subreddit

string

The subreddit to resolve for.

Returns

Promise<string>


getNoteReadPath()

getNoteReadPath(slug, subreddit): Promise<string>

Defined in: extension/data/util/wiki/wikiPaths.ts:342

Returns the canonical read path for an individual subreddit note’s slug.

Parameters

slug

string

The note slug (page name suffix after the notes prefix).

subreddit

string

The subreddit to resolve for.

Returns

Promise<string>


getNoteWritePaths()

getNoteWritePaths(slug, subreddit): Promise<string[]>

Defined in: extension/data/util/wiki/wikiPaths.ts:353

Returns one or more write paths for an individual subreddit note’s slug, canonical first, mirroring getWikiWritePaths fan-out semantics.

Parameters

slug

string

The note slug (page name suffix after the notes prefix).

subreddit

string

The subreddit to resolve for.

Returns

Promise<string[]>


getWikiReadPath()

getWikiReadPath(name, subreddit): Promise<string>

Defined in: extension/data/util/wiki/wikiPaths.ts:302

Returns the single canonical read path for a logical wiki page: the NXG path, except for legacyFallback subs (which have no NXG pages to read).

Parameters

name

WikiPageName

The logical page name.

subreddit

string

The subreddit to resolve for.

Returns

Promise<string>


getWikiWritePaths()

getWikiWritePaths(name, subreddit): Promise<string[]>

Defined in: extension/data/util/wiki/wikiPaths.ts:318

Returns one or more write paths for a logical wiki page, canonical first. Subs with compat on return [nxg, legacy]; compat-off subs return [nxg]; legacyFallback subs return [legacy].

Contract for writers: index 0 is canonical and its failure is fatal to the save; any subsequent entries are mirrors whose failure is non-fatal (warn and continue - the next successful save refreshes them).

Parameters

name

WikiPageName

The logical page name.

subreddit

string

The subreddit to resolve for.

Returns

Promise<string[]>


peekWikiLayout()

peekWikiLayout(subreddit, options?): Promise<WikiLayout>

Defined in: extension/data/util/wiki/wikiPaths.ts:92

Like resolveWikiLayout, but never shows feedback toasts. Used by the settings UI, which displays problems like missing NXG pages in-place.

Parameters

subreddit

string

The subreddit to inspect.

options?

ResolveWikiLayoutOptions = {}

Resolution options (see ResolveWikiLayoutOptions).

Returns

Promise<WikiLayout>


resolveWikiLayout()

resolveWikiLayout(subreddit, options?): Promise<WikiLayout>

Defined in: extension/data/util/wiki/wikiPaths.ts:79

Resolves the current wiki layout for a subreddit. Checks the local cache first (performance hint), then falls back to reading the wiki: the toolbox-nxg page first, then toolbox, then a legacy usernotes probe. Read-only - migration to the NXG layout is opt-in via the Wiki Layout settings section (util/wiki/wikiMigration!migrateSubredditToNxg). Never silently downgrades a migrated subreddit to legacy reads.

For subs the viewer does not moderate, resolution short-circuits to a notModerated layout without any wiki read (Toolbox has no business reading a non-moderated sub’s config); pass allowNonModerated to override that for legitimate cross-sub reads.

Parameters

subreddit

string

The subreddit to resolve.

options?

ResolveWikiLayoutOptions = {}

Resolution options (see ResolveWikiLayoutOptions).

Returns

Promise<WikiLayout>

Interfaces

ResolveWikiLayoutOptions

Defined in: extension/data/util/wiki/wikiPaths.ts:54

Options controlling a wiki-layout resolution.

Properties

allowNonModerated?

optional allowNonModerated?: boolean

Defined in: extension/data/util/wiki/wikiPaths.ts:61

Resolve even when the viewer does not moderate the sub. Off by default so a non-moderated sub short-circuits to a notModerated layout without firing any wiki reads. Opt in only for legitimate cross-sub reads (e.g. removal reasons following a getfrom redirect into a sub you don’t moderate).