Persist space icon order

This commit is contained in:
2026-02-18 21:28:21 +00:00
committed by hodlbod
parent e0511edc4d
commit 64a62a72d1
3 changed files with 69 additions and 45 deletions
+15
View File
@@ -37,6 +37,7 @@ import {
makeList,
addToListPublicly,
removeFromListByPredicate,
updateList,
getTag,
getListTags,
getRelayTagValues,
@@ -148,6 +149,20 @@ export const removeSpaceMembership = async (url: string) => {
return publishThunk({event, relays})
}
export const setSpaceMembershipOrder = async (urls: string[]) => {
const list = get(userGroupList) || makeList({kind: ROOMS})
const orderedUrls = uniq(urls.map(normalizeRelayUrl))
const relayTags = list.publicTags.filter(t => t[0] === "r")
const otherPublicTags = list.publicTags.filter(t => t[0] !== "r")
const relayTagByUrl = new Map(relayTags.map(t => [normalizeRelayUrl(t[1]), t]))
const orderedRelayTags = orderedUrls.map(url => relayTagByUrl.get(url) || ["r", url])
const publicTags = [...orderedRelayTags, ...otherPublicTags]
const event = await updateList(list, {publicTags}).reconcile(nip44EncryptToSelf)
const relays = uniq([...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
return publishThunk({event, relays})
}
export const addRoomMembership = async (url: string, h: string) => {
const list = get(userGroupList) || makeList({kind: ROOMS})
const newTags = [