Skip to main content

Module synced_prefs

Module synced_prefs 

Source
Expand description

Account preferences that follow you between your own devices: the block list, the mute list, and nicknames.

Each is a private, parameterized-replaceable kind 30078 with its own d tag, NIP-44 self-encrypted, riding the SAME self-sync subscription as the Community, Invite and Pinned lists — so each inherits boot sync, reconnect re-sync and live cross-device edits with no new plumbing.

Vector’s own lists, deliberately not NIP-51. Social clients disagree on what a mute is — several treat it as a soft block — so round-tripping through the shared kind-10000 would blur the mute/block separation Vector draws on purpose. Isolation costs interop and buys exactness.

Newest wins, whole list. These are one person’s settings edited from one device at a time, so the replaceable event’s own last-write-wins is the merge. A device that was offline can therefore republish over a change it never saw; the pre-publish fetch below shrinks that window, and these are deliberate, infrequent actions rather than latency-sensitive ones.

Structs§

IdList
A set of ids (npubs for blocks, chat ids for mutes).
NicknameMap
npub → nickname. A map rather than a list so a rename replaces rather than duplicates, and so the wire form stays stable under reordering.
NotifyEntry
One scope’s notification settings on the wire. Level is spelled out rather than numbered so a future rung does not silently become an old one, and an absent field means inherit, exactly as it does on disk.
NotifyMap
scope id → settings, for communities, channels and DMs alike.

Enums§

Pref
Which list a call refers to. Keeps one set of network/storage plumbing for all three rather than three near-identical copies that can drift.

Constants§

ALL_PREFS
Every list, in the order hydration walks them. Notify comes after Mutes so a device holding both applies the richer one last and wins the overlap.
BLOCKS_D_TAG
MUTES_D_TAG
NICKNAMES_D_TAG
NOTIFY_D_TAG
RAIL_D_TAG

Functions§

fetch_raw
Fetch a list’s relay copy as raw JSON, or None when the relays hold none.
flush_rail
Publish the arrangement if it has unsent edits.
hydrate_all
Pull every list once at login and apply it, so this device is reconciled before the user can touch anything. The live subscription also delivers these, but it races the user; this does not.
ingest_remote
Consume a sibling device’s update. Never republishes — the relay echoes our own publishes back on this same subscription, and answering an echo with a publish loops forever.
is_hydrated
Has pref been reconciled with the relays yet this session?
load_blocks
load_local_raw
Raw JSON of a list’s local mirror. Callers parse into whichever shape the list uses; the storage layer stays shape-agnostic.
load_mutes
load_nicknames
load_notify
load_rail
mark_hydrated
Mark pref reconciled. Called when a copy is applied AND when the relays confirm none exists — “there is nothing to preserve” is just as reconciled as having read it, and without that a first-ever account could never publish.
publish_raw
Persist locally, then publish self-encrypted.
rail_is_dirty
Whether the rail holds edits the relays have not seen.
save_local_raw
save_rail_debounced
Commit an arrangement: on disk now, on the relays once the dragging stops.