Move from topic to room using tilde

This commit is contained in:
Jon Staab
2024-09-23 10:28:33 -07:00
parent 88000d02ba
commit 4c9b7da586
12 changed files with 75 additions and 67 deletions
+6 -5
View File
@@ -14,7 +14,7 @@ import {
loadMutes,
followsByPubkey,
} from "@welshman/app"
import {MEMBERSHIPS, INDEXER_RELAYS} from "@app/state"
import {ROOM, MEMBERSHIPS, INDEXER_RELAYS} from "@app/state"
// Utils
@@ -95,9 +95,9 @@ export const updateList = async (kind: number, modifyTags: ModifyTags) => {
export const addSpaceMembership = (url: string) =>
updateList(MEMBERSHIPS, (tags: string[][]) => uniqBy(t => t.join(""), [...tags, ["r", url]]))
export const addRoomMembership = (url: string, topic: string) =>
export const addRoomMembership = (url: string, room: string) =>
updateList(MEMBERSHIPS, (tags: string[][]) =>
uniqBy(t => t.join(""), [...tags, ["t", topic, url]]),
uniqBy(t => t.join(""), [...tags, [ROOM, room, url]]),
)
export const removeSpaceMembership = (url: string) =>
@@ -105,5 +105,6 @@ export const removeSpaceMembership = (url: string) =>
tags.filter(t => !equals(["r", url], t) && t[2] !== url),
)
export const removeRoomMembership = (url: string, topic: string) =>
updateList(MEMBERSHIPS, (tags: string[][]) => tags.filter(t => !equals(["t", topic, url], t)))
export const removeRoomMembership = (url: string, room: string) =>
updateList(MEMBERSHIPS, (tags: string[][]) => tags.filter(t => !equals([ROOM, room, url], t)))