diff options
| author | Adrien Hopkins <[email protected]> | 2026-01-09 09:00:32 -0500 |
|---|---|---|
| committer | Adrien Hopkins <[email protected]> | 2026-01-09 09:00:32 -0500 |
| commit | 9175c76d7f03c0c62323202fdab3e4ab35854855 (patch) | |
| tree | 6195dc3eac3c55fbd84cd32f34077dab10ec7ac5 /src/lib | |
| parent | 4bc94247c382898c0e0d76439fe0bdce68755d69 (diff) | |
| download | coinos-ui-9175c76d7f03c0c62323202fdab3e4ab35854855.tar.gz coinos-ui-9175c76d7f03c0c62323202fdab3e4ab35854855.zip | |
Hide muted chats
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/nip51.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/nip51.ts b/src/lib/nip51.ts new file mode 100644 index 00000000..142f0bbf --- /dev/null +++ b/src/lib/nip51.ts @@ -0,0 +1,47 @@ +import { SimplePool } from 'nostr-tools/pool'; +const pool = new SimplePool(); + +import { PUBLIC_DM_RELAYS } from '$env/static/public'; +const DM_RELAYS_LIST = PUBLIC_DM_RELAYS.split(','); + +// export const mute = async (pubkey: string, hidden: bool) => { + +// } + +// export const unmute = async (pubkey: string) => { + +// } + +export const mutedAccounts = async (user: object): Set<string> => { + const { shown, hidden } = await getMuteLists(user); + let muted = new Set<string>(); + for (const pubkey of shown) { + muted.add(pubkey); + } + for (const pubkey of hidden) { + muted.add(pubkey); + } + return muted; +} + +const getMuteLists = async (user: object): object => { + const listEvents = await pool.querySync( + DM_RELAYS_LIST, { kinds: [10000], "authors": [user.pubkey], limit: 1 } + ); + if (listEvents.length == 0) { + return { shown: [], hidden: [] }; + } + + let shown = []; + for (const tag of listEvents[0].tags) { + if (tag.length >= 2 && tag[0] == "p") { + shown.push(tag[1]); + } + } + + return { shown, hidden: [] }; +} + +// const publishMuteList = async (shown: Array<string>, hidden: Array<string>) => { + +// } |
