moderator-toolbox-nxg-for-reddit / modules/shared/proposals/traineeState
modules/shared/proposals/traineeState¶
Functions¶
ensureTraineeStateLoaded()¶
ensureTraineeStateLoaded(
subreddit):Promise<void>
Defined in: extension/data/modules/shared/proposals/traineeState.ts:119
Loads (and caches) a subreddit’s trainee set from its Toolbox config. Coalesces concurrent loads for the same subreddit.
Parameters¶
subreddit¶
string
The subreddit to load.
Returns¶
Promise<void>
getProposerName()¶
getProposerName():
string
Defined in: extension/data/modules/shared/proposals/traineeState.ts:99
The current username (original case), or ‘’ if not yet resolved.
Returns¶
string
invalidateTraineeState()¶
invalidateTraineeState(
subreddit?):void
Defined in: extension/data/modules/shared/proposals/traineeState.ts:261
Drops cached trainee state so the next check re-reads config (e.g. after the trainee list is edited in settings).
Parameters¶
subreddit?¶
string
The subreddit to invalidate, or omit to clear all.
Returns¶
void
isActionGuardedFor()¶
isActionGuardedFor(
subreddit,actionType):Promise<boolean>
Defined in: extension/data/modules/shared/proposals/traineeState.ts:214
Whether actionType is guarded (captured for review) for subreddit. Used by the
gateway to decide per-action capture once a user is known to be a trainee. A sub
whose config omits guardedActions guards everything (returns true for any type);
otherwise only the listed types are guarded. Ensures the sub’s state is warm first.
Parameters¶
subreddit¶
string
The subreddit to check.
actionType¶
string
The ProposedActionType discriminant being attempted.
Returns¶
Promise<boolean>
isTraineeAnywhereSync()¶
isTraineeAnywhereSync():
boolean
Defined in: extension/data/modules/shared/proposals/traineeState.ts:183
Synchronous “is the current user a trainee in any subreddit whose state is warm?” Backs the capture guard’s fail-closed decision when an action’s subreddit can’t be resolved on a multi-sub page. Answers from warm state only (false until warm), so it never blocks a non-trainee, and before the all-subs warm completes the worst case is the prior fail-open behavior. Warmed across moderated subs by warmAllTraineeStates.
Returns¶
boolean
isTraineeFor()¶
isTraineeFor(
subreddit):Promise<boolean>
Defined in: extension/data/modules/shared/proposals/traineeState.ts:200
Accurate async capture check used by the gateway: ensures the current user and the subreddit’s trainee set are loaded, then tests membership.
Parameters¶
subreddit¶
string
The subreddit to check.
Returns¶
Promise<boolean>
isTraineeForSync()¶
isTraineeForSync(
subreddit):boolean
Defined in: extension/data/modules/shared/proposals/traineeState.ts:165
Synchronous capture check for the guard backstop: true only when the current user and the subreddit’s trainee set are already warm and the user is a trainee. Returns false (fail-open) when state isn’t loaded yet - the gateway’s async path is the accurate decision; this is the secondary net.
Parameters¶
subreddit¶
string
The subreddit to check.
Returns¶
boolean
isTraineeStateWarm()¶
isTraineeStateWarm():
boolean
Defined in: extension/data/modules/shared/proposals/traineeState.ts:64
Whether the current page’s trainee state has warmed (see pageWarmReady).
Returns¶
boolean
loadCurrentUser()¶
loadCurrentUser():
Promise<void>
Defined in: extension/data/modules/shared/proposals/traineeState.ts:79
Resolves and caches the current username (idempotent, coalesced).
Returns¶
Promise<void>
resolveProposerName()¶
resolveProposerName():
Promise<string>
Defined in: extension/data/modules/shared/proposals/traineeState.ts:109
Resolves the current username, awaiting the (coalesced) current-user load first so callers that must record a proposer - e.g. a forced second-opinion capture that skips the trainee-state async path - never read the cache before it warms. Returns ‘’ only when the load itself could not resolve a user.
Returns¶
Promise<string>
setTraineeStateWarm()¶
setTraineeStateWarm(
ready):void
Defined in: extension/data/modules/shared/proposals/traineeState.ts:74
Records whether the current page’s trainee state is warm. The runtime sets false on
each navigation (before kicking the page’s warm) and true once that warm settles, so
the synchronous checks are only trusted to answer false when they actually can.
Parameters¶
ready¶
boolean
Whether the page’s warm has completed.
Returns¶
void
warmAllTraineeStates()¶
warmAllTraineeStates():
Promise<void>
Defined in: extension/data/modules/shared/proposals/traineeState.ts:233
Warms the trainee set for every subreddit the current user moderates, so the synchronous trainee check is reliable on multi-sub pages (the cross-sub modqueue), where an item can belong to any moderated subreddit and the per-page warm can’t know which until it’s actioned. Bounded fan-out (config reads are cached/cheap after the first). Coalesced: concurrent and repeat calls share one pass - a successful warm stays cached until invalidateTraineeState; a failed listing resets so a later navigation can retry.
Returns¶
Promise<void>