moderator-toolbox-nxg-for-reddit / modules/subredditnotes/moduleapi
modules/subredditnotes/moduleapi¶
Functions¶
loadNoteIndex()¶
loadNoteIndex(
subreddit):Promise<{bootstrapped:boolean;index:SubredditNoteIndex; }>
Defined in: extension/data/modules/subredditnotes/moduleapi.ts:28
Reads the note index for a subreddit, normalizing and migrating as needed.
If the stored index is absent or malformed, builds one from existing wiki
pages. With 6.x compatibility on, the legacy index is union-merged in so
notes created from 6.x show up - the merge sets bootstrapped, and the
caller’s persist writes both pages, healing the divergence.
The bootstrapped flag is true when the caller should persist the index.
Parameters¶
subreddit¶
string
Returns¶
Promise<{ bootstrapped: boolean; index: SubredditNoteIndex; }>
readNotePage()¶
readNotePage(
subreddit,slug):Promise<{ok:false;reason:"no_page"|"unknown_error"|"invalid_json"; } | {data:string;ok:true; } | {ok:false;reason:"no_page"; }>
Defined in: extension/data/modules/subredditnotes/moduleapi.ts:146
Reads a single note page from the wiki as raw markdown.
Returns a discriminated union - check .ok before using .data.
With 6.x compatibility on, the legacy page is consulted too. When the two sides diverge, the newer revision wins: a newer legacy page means a 6.x edit (it’s adopted and immediately copied to the NXG page), while a newer NXG page means a previous mirror write failed (the next save heals it). Newer-wins, rather than blind legacy-wins, because under NXG-first writes a partial failure leaves the NXG side ahead.
Parameters¶
subreddit¶
string
slug¶
string
Returns¶
Promise<{ ok: false; reason: "no_page" | "unknown_error" | "invalid_json"; } | { data: string; ok: true; } | { ok: false; reason: "no_page"; }>
writeNoteIndex()¶
writeNoteIndex(
subreddit,index,reason):Promise<void>
Defined in: extension/data/modules/subredditnotes/moduleapi.ts:104
Writes the note index for a subreddit to the wiki, fanning out to the legacy mirror after the canonical NXG write when 6.x compatibility is on. Each destination gets its own schema: the NXG page is written as v2 (with freshly recomputed tag and author aggregates), while the legacy page stays in the v1 shape older toolbox builds expect.
Parameters¶
subreddit¶
string
Target subreddit.
index¶
Index to persist.
reason¶
string
Edit reason shown in the wiki revision history.
Returns¶
Promise<void>
writeNotePage()¶
writeNotePage(
subreddit,slug,content,reason):Promise<void>
Defined in: extension/data/modules/subredditnotes/moduleapi.ts:195
Writes a single note page to the wiki, fanning out to the legacy mirror after the canonical NXG write when 6.x compatibility is on.
Parameters¶
subreddit¶
string
Target subreddit.
slug¶
string
Note slug (page name suffix after the notes prefix).
content¶
string
Markdown content to write.
reason¶
string
Edit reason shown in the wiki revision history.
Returns¶
Promise<void>