Expand description
Global state management — ChatState, globals, processing gate.
All Tauri-specific globals (TAURI_APP) have been removed. Event emission
uses the EventEmitter trait via crate::traits::emit_event.
Structs§
- Chat
State - Pending
Invite Acceptance - Session
Guard - Lightweight handle that remembers the session generation at the moment
it was created. Pass it into background tasks (via move-capture into a
spawned future) and check
is_valid()before any side-effect. - Wrapper
IdCache
Statics§
- ACTIVE_
CHAT - Chat id currently visible to the user with auto-mark eligibility — set by the frontend when the chat is open AND pinned to bottom AND the window is active. Used by the inbound event handler to mark new messages read on arrival, so the dock badge never bumps for messages the user is actively watching. Cleared when any of those conditions flips.
- BLOSSOM_
SERVERS - Blossom media servers with failover. Held in a mutex so the per-account resolver (defaults minus disabled + enabled customs) can refresh it after edits and on login. Until the DB is open, falls back to the seed list.
- DISCOVERY_
READ_ ONLY_ RELAYS - Read-only Discovery Relays: queried when SYNCING relay lists but never published to. Ditto acks stranger kind-10050 writes with OK true and then silently drops them, so counting it as a publish landing would falsely advance the list-freshness anchor — but it serves ESTABLISHED accounts’ lists honestly, and those are exactly the users whose existing list a fresh Vector login must find before it dares bootstrap-publish.
- DISCOVERY_
RELAYS - Discovery Relays: widely-used indexers queried/written for relay-list events (kind 10050) ONLY — never DMs, profiles, or communities. They give list syncs and publishes a rendezvous point that doesn’t depend on the user’s own relay set overlapping anyone else’s. Every entry must be verified to ACCEPT AND SERVE kind 10050 from unknown pubkeys (write + readback); accept-then-silently-drop policy relays reduce coverage invisibly.
- ENCRYPTION_
ENABLED - ENCRYPTION_
KEY - MNEMONIC_
SEED - MY_
PUBLIC_ KEY - MY_
SECRET_ KEY - NOSTR_
CLIENT - NOTIFIED_
WELCOMES - PENDING_
BUNKER_ SETUP - Staged bunker metadata between
connect_bunker/start_nostrconnect_sessionand the subsequent encryption-flow commit. URL is wrapped inZeroizingbecause it contains the NIP-46 single-use pairing secret; the pubkey hex is non-secret.setup_encryption/skip_encryptionreads this whensigner_kind() == Bunkerto write the right settings rows viacommit_bunker_account_setup. - PENDING_
EVENTS - PENDING_
INVITE - PENDING_
NSEC - PROCESSING_
GATE - STATE
- TRUSTED_
RELAYS - WRAPPER_
ID_ CACHE
Functions§
- active_
trusted_ relays - bump_
session_ generation - Advance the session generation. Called at the start of
reset_session()so any task that captured the previous value before the swap can detect it and short-circuit before writing to the new account’s state. - clear_
my_ public_ key - Clear
MY_PUBLIC_KEY. The Nostr client is taken separately viatake_nostr_client()so the caller can shut it down before this clear. - clear_
pending_ bunker_ setup - clear_
pending_ invite - close_
processing_ gate - current_
session_ generation - Snapshot of the current session generation.
- discovery_
relay_ iter - Every discovery relay url (writable + read-only) — the fetch/pool/identity
set. Publish copies use
DISCOVERY_RELAYSalone. - get_
active_ chat - get_
blossom_ servers - has_
active_ session - Returns
truewhen there is an active session (client + pubkey set). - init_
blossom_ servers - init_
encryption_ enabled - is_
encryption_ enabled_ fast - is_
processing_ allowed - my_
public_ key - Get the active user’s public key.
PublicKeyisCopy, so this is by-value. - nostr_
client - Get a clone of the active Nostr client. The clone is cheap —
Clientis internallyArc-counted, so all clones share connections, signers, and subscription state. ReturnsNonewhen no session is active. - open_
processing_ gate - pending_
bunker_ setup - pending_
invite - resolve_
encryption_ enabled - Resolve “is this account encrypted?” from raw DB settings. Single source of truth — every caller (crypto::is_encryption_enabled, init_encryption_enabled, Android bg-sync) delegates here, so the answer is consistent regardless of code path.
- resolve_
encryption_ enabled_ from_ db - Resolve from the current account’s DB via the global settings helper.
Returns
falseif the DB is not yet open. - set_
active_ chat - set_
encryption_ enabled - set_
my_ public_ key - Install the active user’s public key for the current session.
- set_
nostr_ client - Install the Nostr client for the current session. Replaces any prior client
without shutting it down —
reset_session()is responsible for orderly teardown of the outgoing client. - set_
pending_ bunker_ setup - set_
pending_ invite - take_
nostr_ client - Atomically take the current Nostr client out of global state.
Used by
reset_session()so the post-take shutdown call doesn’t race with new readers.