Expand description
Pinned Chats — the account’s favourite conversations, synced across its own devices.
A pin is just an id: a DM’s npub, or a Community’s id (pinning a Community hoists the chat row of its primary channel). The list is ORDERED, and that order is the display order.
On the wire: a parameterized-replaceable kind 30078 with the d tag
vector/pinned, content NIP-44 self-encrypted — the same shape and the same
self-sync subscription as the Community and Invite lists, so it inherits boot
sync, reconnect re-sync and live cross-device edits without new plumbing.
kind: 30078 (APPLICATION_SPECIFIC)
tags: ["d", "vector/pinned"]
content: nip44(self, {"v":1,"chats":["npub1…","<community-id-hex>"]})Ids are opaque here. A pin for a chat this device has not synced yet is
carried through every read and republish untouched: dropping “unknown” ids
would let the device that knows least erase the others’ pins. Nothing
resolves an id to a chat in this module — is_pinned is consulted at
render time, so a chat that syncs in later is pinned the moment it paints.
Structs§
- Pinned
Chats - The synced list.
vis a forward-compat marker, not a gate: an unknown version still round-trips its ids rather than being discarded.
Constants§
- MAX_
PINNED - Base (free, tier-0) pin cap. Named const for the frontend mirror.
- PINNED_
D_ TAG - The d tag identifying this list among our other kind-30078 self-lists.
Functions§
- effective_
max_ pinned - Pin cap for the current account, scaled by effective tier. Gate the pin ACTION on this — never the read or render path.
- fetch_
pinned - Fetch the relay copy. A copy older than our last publish loses to the local mirror — otherwise a relay still serving the pre-edit event would undo the pin the user just made.
- ingest_
remote_ event - Consume a remotely-received list event (the live cross-device path). Does NOT republish: the relay echoes our own publishes back on the same subscription, and answering an echo with a publish loops forever.
- is_
pinned - Is this chat id pinned? The render-time question — deliberately a lookup against the list rather than a flag stamped onto chats when they sync, so a chat that arrives after its pin is pinned on its first paint.
- load_
local - The local mirror. Every read path goes through here so the UI never waits on a relay to know what is pinned.
- pin_
chat - Pin a chat: commit locally and RETURN, then sync in the background.
- pin_
position - Pin order for
id, orNonewhen unpinned. Sorts the chat list. - publish
- Persist
listlocally and publish it self-encrypted. - save_
local - unpin_
chat - Unpin a chat. Same commit-then-sync shape as
pin_chat.