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, nicknames, and the general settings document.

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§

AdoptedSettings
The outcome of taking a relay copy of the settings document.
ArchiveMap
chat id → the newest message time the archiving device had seen (unix ms). A chat counts as archived only while nothing newer has been said in it, so a reply brings it back on every device whether or not this list has caught up.
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.
RelayCopy
A list as one relay copy carries it: the plaintext and when it was signed.
StreamerSettings
Streamer Mode: masks everyone who has not opted in, on every device of the account.
SyncedSettings
Account-wide switches that follow the user between devices.

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.
ARCHIVE_D_TAG
BANNERS_D_TAG
BLOCKS_D_TAG
MUTES_D_TAG
NICKNAMES_D_TAG
NOTIFY_D_TAG
RAIL_D_TAG
SETTINGS_D_TAG
START_D_TAG
STREAMER_NOTIF_LEVELS
The streaming overlay’s levels, in the spelling the wire and the page share.

Functions§

adopt_settings
Take a relay copy of the settings (None = the relays hold none) and mark them reconciled.
edit_layout
Load, change and commit one layout, one edit at a time: commands run on several threads, and two read-modify-writes interleaved would drop one of them. Returns the layout and whether anything moved (nothing is written when nothing did).
fetch_raw
Fetch a list’s newest relay copy, Ok(None) when the relays hold none.
flush_layout
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 answers an echo with a publish — the relay echoes our own publishes back on this same subscription, and that loops forever. The one republish is a held settings intent the copy lacks, which an echo of our own latest publish already carries. None for a settings copy older than this device’s, which changes nothing.
is_hydrated
Has pref been reconciled with the relays yet this session?
layout_is_dirty
Whether a layout holds edits the relays have not seen.
live_d_tags
Every self-synced list’s d tag, for the live subscriptions: built from ALL_PREFS, so a new list can’t be read at boot and then never heard from again.
load_archive
load_blocks
load_hidden_banners
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
load_settings
load_start
The Main Menu’s pins, in the rail’s shape: keys are pin keys (crate::start_menu).
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. Settings always go out from the local copy, through publish_settings, which keeps their signing order.
publish_settings
Publish the local settings, signed after every copy this device has adopted or signed so the relays keep it over them.
revoke_archive
Forget an archive that activity at active_at has outlived, on this device only. An outlived entry is harmless (every reader looks past it) and leaves the relays with the next archive change; publishing it from every device the message reaches would race them against each other. The bool says whether anything changed.
save_layout_debounced
Commit an arrangement: on disk now, on the relays once the dragging stops.
save_local_raw
set_advanced
Turn Advanced Mode on or off, committed locally. The caller publishes.
set_archived
Archive a chat as of at (Some) or bring it back (None), committed locally. The caller publishes. Refused until the relay copy has been read, for the same reason as the banners.
set_banner_hidden
Hide or show a community’s banner, committed locally. The caller publishes.
set_players
Allow or refuse embedded video players. Held like set_streamer_on: switching them off is a privacy choice, so it must not wait for the relay copy.
set_streamer_notif
Choose what notifications additionally hide while live. Held like set_streamer_on.
set_streamer_on
Go live or stop, in effect at once. The caller publishes.
set_streamer_wallpapers
Choose whether chat wallpapers stay plain while live. Held like set_streamer_on.