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

util/wiki/wikiLayoutCache

Functions

clearWikiLayoutCache()

clearWikiLayoutCache(subreddit?): Promise<void>

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:67

Clears the cached wiki layout for a subreddit (or all subreddits), both in-session and persistent. Call after compat toggles or repair migrations so the next resolution re-reads the wiki.

Parameters

subreddit?

string

The subreddit to clear, or undefined to clear everything.

Returns

Promise<void>


getCachedWikiLayouts()

getCachedWikiLayouts(): Promise<Record<string, WikiLayout>>

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:100

Returns every locally known layout (session + persistent cache), keyed by subreddit. A display hint only - entries may be missing or stale.

Returns

Promise<Record<string, WikiLayout>>


setCachedWikiLayout()

setCachedWikiLayout(layout, persist): Promise<void>

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:88

Records a subreddit’s resolved layout in the session cache and, for confidently-known states (no read errors or missing pages), the persistent TTL cache. Called by both the resolver and the migration module on success.

Parameters

layout

WikiLayout

The layout to record.

persist

boolean

Whether to also write the persistent cache entry.

Returns

Promise<void>

Type Aliases

WikiLayout

WikiLayout = object

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:28

Resolved wiki layout for a subreddit. The local cache of these is a performance hint only - the authority is the wiki itself.

Properties

compatibilityWrites

compatibilityWrites: boolean

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:32

Whether the legacy 6.x mirror is maintained (write fan-out + read-time reconciliation).

fallbackReason?

optional fallbackReason?: "notMod" | "bootstrapFailed" | "resolveError"

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:40

Why this sub is stuck on legacy reads (only when state is 'legacyFallback').

notModerated?

optional notModerated?: true

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:47

Set when the viewer does not moderate the sub: layout resolution skipped all wiki reads (Toolbox has no business reading a non-moderated sub’s config / usernotes). Readers treat this exactly like “no config / no notes”. Held session-only so getting modded later re-resolves on the next page session.

nxgMissing?

optional nxgMissing?: boolean

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:38

Set when the sub is marked as bootstrapped (tombstone in toolbox) but the NXG pages are missing - deleted externally. Reads will fail until the user runs a repair migration; we never silently fall back to legacy.

state

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:30

subreddit

subreddit: string

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:29


WikiLayoutState

WikiLayoutState = "nxg" | "legacyFallback"

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:22

Which wiki layout a subreddit is in:

  • 'nxg' - the NXG paths are canonical: read from them, write them first. Covers bootstrapped subs and data-less subs alike (pages are created on bootstrap or first save).

  • 'legacyFallback' - legacy data exists but the NXG pages could not be created (non-mod, bootstrap failure, or a transient resolve error); reads and writes stay on the legacy paths so data lands somewhere 6.x-visible.

Variables

LAYOUT_CACHE_KEY

const LAYOUT_CACHE_KEY: "wikiLayoutCache" = 'wikiLayoutCache'

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:51

Persistent layout cache key.


sessionLayouts

const sessionLayouts: Map<string, WikiLayout>

Defined in: extension/data/util/wiki/wikiLayoutCache.ts:59

Session-scoped layout state. The persistent TTL cache only ever holds layouts we are confident about (fresh/legacy/migrated); transient or error states (read failures, nxgMissing) live here only, so they are re-evaluated on the next page session rather than sticking around.