Closes #17 Co-authored-by: Jon Staab <shtaab@gmail.com> Reviewed-on: #78 Co-authored-by: triesap <tyson@radroots.org> Co-committed-by: triesap <tyson@radroots.org>
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user