moderator-toolbox-nxg-for-reddit / modules/removalreasons/nativeSync

modules/removalreasons/nativeSync

Functions

mergeNativeReasons()

mergeNativeReasons(existing, native, ignored?): NativeSyncResult

Defined in: extension/data/modules/removalreasons/nativeSync.ts:81

Merges a native reason set into the configured reasons, one way: Reddit owns the title and text of every linked reason, and everything else on that reason is left alone.

Ordering is preserved rather than imposed. Existing reasons stay where the moderator put them (reordering is a first-class editor affordance, and hand-written reasons interleave with synced ones), and newly imported reasons are appended in Reddit’s display order.

The input is never mutated, and entries that need no change are returned by reference, so callers can use identity to detect a no-op.

Parameters

existing

RemovalReason[]

The currently configured reasons.

native

NativeRemovalReason[]

The native reasons fetched from Reddit, in display order.

ignored?

string[]

Native ids a moderator deleted locally; never re-imported.

Returns

NativeSyncResult


nativeReasonsFingerprint()

nativeReasonsFingerprint(native): string

Defined in: extension/data/modules/removalreasons/nativeSync.ts:55

Digests a native reason set so a later sync can tell at a glance whether anything upstream changed, without merging.

Deliberately order-independent: the merge never repositions existing reasons, so a moderator reordering reasons in Reddit’s mod tools produces no toolbox change. Were order part of the digest, such a reorder would leave the fingerprint permanently mismatched while every merge came back empty. Sorting by id keeps the useful invariant that a changed fingerprint means the merge has work to do.

Parameters

native

NativeRemovalReason[]

The native reasons to digest.

Returns

string


stripNativeReasons()

stripNativeReasons(existing): object

Defined in: extension/data/modules/removalreasons/nativeSync.ts:152

Drops every reason linked to a native one, for when a subreddit turns the sync off.

A linked reason’s title and message are Reddit’s, so what would survive the sync being switched off is a frozen copy nobody maintains. The toolbox-owned extras on those reasons (flair, usernote defaults) go with them, which is why the caller confirms first.

The input is never mutated, and the surviving entries are returned by reference.

Parameters

existing

RemovalReason[]

The currently configured reasons.

Returns

object

reasons

reasons: RemovalReason[]

removed

removed: number

Interfaces

NativeSyncResult

Defined in: extension/data/modules/removalreasons/nativeSync.ts:7

Outcome of merging a native reason set into the configured reasons.

Properties

added

added: number

Defined in: extension/data/modules/removalreasons/nativeSync.ts:13

Count of native reasons appended as new toolbox reasons.

changed

changed: boolean

Defined in: extension/data/modules/removalreasons/nativeSync.ts:11

Whether anything actually moved; false means the caller should not write.

reasons

reasons: RemovalReason[]

Defined in: extension/data/modules/removalreasons/nativeSync.ts:9

The merged reason list. Unchanged entries keep their original object identity.

removed

removed: number

Defined in: extension/data/modules/removalreasons/nativeSync.ts:17

Count of linked reasons dropped because they no longer exist upstream.

updated

updated: number

Defined in: extension/data/modules/removalreasons/nativeSync.ts:15

Count of linked reasons whose title or text was refreshed from Reddit.