moderator-toolbox-nxg-for-reddit / modules/removalreasons/features/syncNativeReasons

modules/removalreasons/features/syncNativeReasons

Functions

getLastNativeSyncCheck()

getLastNativeSyncCheck(subreddit): Promise<number | undefined>

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:106

Epoch milliseconds of the last time this browser successfully read Reddit’s removal reasons for a subreddit, or undefined if it never has.

Local to this user rather than shared through the config, and the only evidence the editor can show that the sync is alive: lastSyncedAt moves only when a sync changes something, so it stands still for a subreddit whose reasons have settled.

Parameters

subreddit

string

The subreddit to look up.

Returns

Promise<number | undefined>


getLastNativeSyncFailure()

getLastNativeSyncFailure(subreddit): Promise<NativeSyncFailure | undefined>

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:156

The last recorded failure for a subreddit, or undefined if its most recent run got through. Local to this user, like getLastNativeSyncCheck.

Parameters

subreddit

string

The subreddit to look up.

Returns

Promise<NativeSyncFailure | undefined>


resetNativeSyncThrottle()

resetNativeSyncThrottle(): void

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:78

Clears the in-session throttle. Exposed for tests.

Returns

void


syncNativeReasons()

syncNativeReasons(subreddit, options?): Promise<NativeSyncOutcome>

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:173

Imports a subreddit’s native removal reasons into its toolbox config, one way.

Cheap gates run first so the common case (not opted in) costs nothing, and the stored fingerprint short-circuits before any merge when nothing upstream changed. Never rejects: this runs in the background off a drawer open, so a failure is logged and recorded for the config editor to report rather than thrown at the moderator mid-removal.

Parameters

subreddit

string

The subreddit to sync.

options?

Run options. force bypasses the throttle and the native reason cache (for the manual button); silent suppresses the save’s feedback toasts and defaults to true unless forced.

force?

boolean

silent?

boolean

Returns

Promise<NativeSyncOutcome>

Interfaces

NativeSyncFailure

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:111

A background sync run that did not complete, kept so the editor can report it.

Properties

at

at: number

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:113

Epoch milliseconds the failure happened.

message

message: string

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:117

The underlying error’s message, for the editor to show verbatim.

stage

stage: "fetch" | "save"

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:115

Whether the fetch or the config write was what failed.


NativeSyncOutcome

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:43

Why a sync run ended, for callers that surface the result.

Properties

added?

optional added?: number

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:56

removed?

optional removed?: number

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:58

status

status: "disabled" | "redirected" | "throttled" | "unchanged" | "noneUpstream" | "allIgnored" | "synced" | "failed"

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:55

disabled - not opted in (or no config); redirected - the subreddit takes its reasons from elsewhere; throttled - attempted too recently; unchanged - nothing upstream moved; noneUpstream - Reddit has no removal reasons configured at all; allIgnored - Reddit has some, but every one was deleted here; synced - the config was rewritten; failed - the fetch or the write failed.

The last three “nothing happened” cases are kept apart on purpose. Reporting them all as unchanged tells a moderator their reasons are in sync when in fact none exist to import, which is indistinguishable from success and sends them hunting for a bug.

updated?

optional updated?: number

Defined in: extension/data/modules/removalreasons/features/syncNativeReasons.ts:57