Re-work invite links

This commit is contained in:
Jon Staab
2025-09-05 17:20:12 -07:00
committed by hodlbod
parent 1c37c5bb3d
commit 7217d122b5
10 changed files with 168 additions and 133 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ import {daysBetween} from "@lib/util"
import {
NOTIFIER_RELAY,
INDEXER_RELAYS,
getDefaultPubkeys,
defaultPubkeys,
userRoomsByUrl,
getUrlsForEvent,
loadMembership,
@@ -416,7 +416,7 @@ export const loadUserData = async (pubkey: string, relays: string[] = []) => {
// Load followed profiles slowly in the background without clogging other stuff up. Only use a single
// indexer relay to avoid too many redundant validations, which slow things down and eat bandwidth
promise.then(async () => {
for (const pubkeys of chunk(50, getDefaultPubkeys())) {
for (const pubkeys of chunk(50, get(defaultPubkeys))) {
const relays = sample(1, INDEXER_RELAYS)
await sleep(1000)
+18 -3
View File
@@ -191,12 +191,12 @@ export const entityLink = (entity: string) => `https://coracle.social/${entity}`
export const pubkeyLink = (pubkey: string, relays = Router.get().FromPubkeys([pubkey]).getUrls()) =>
entityLink(nip19.nprofileEncode({pubkey, relays}))
export const getDefaultPubkeys = () => {
export const defaultPubkeys = derived(userFollows, $userFollows => {
const appPubkeys = DEFAULT_PUBKEYS.split(",")
const userPubkeys = shuffle(getPubkeyTagValues(getListTags(get(userFollows))))
const userPubkeys = shuffle(getPubkeyTagValues(getListTags($userFollows)))
return userPubkeys.length > 5 ? userPubkeys : [...userPubkeys, ...appPubkeys]
}
})
const failedUnwraps = new Set()
@@ -459,6 +459,21 @@ export const {
load: makeOutboxLoader(ROOMS),
})
export const membersByUrl = derived(
[defaultPubkeys, membershipsByPubkey],
([$defaultPubkeys, $membershipsByPubkey]) => {
const $membersByUrl = new Map<string, Set<string>>()
for (const pubkey of $defaultPubkeys) {
for (const url of getMembershipUrls($membershipsByPubkey.get(pubkey))) {
addToMapKey($membersByUrl, url, pubkey)
}
}
return $membersByUrl
},
)
// Chats
export const chatMessages = deriveEvents(repository, {