Fix/spurious relay membership prompt (#340)

Co-authored-by: Aditya Chaudhary <30+useradityaa@noreply.coracle.social>
This commit is contained in:
Aditya Chaudhary 2026-08-11 16:45:49 +00:00 committed by hodlbod
parent 8243f4d245
commit c8d003524b
3 changed files with 11 additions and 5 deletions

View file

@ -7,7 +7,7 @@
import RelayDescription from "@app/components/RelayDescription.svelte"
import ProfileCircles from "@app/components/ProfileCircles.svelte"
import {roomLists, user} from "@app/core"
import {deriveUserRooms} from "@app/rooms"
import {userSpaceUrls} from "@app/rooms"
type Props = {
url: string
@ -15,7 +15,6 @@
}
const {url, hideFavorites}: Props = $props()
const rooms = deriveUserRooms(url)
const favorited = $roomLists.pubkeysForUrl(url).$
const favoritedPubkeys = $derived(remove($user.pubkey, $favorited))
</script>
@ -30,7 +29,7 @@
<RelayIcon {url} size={10} class="rounded-full" />
</div>
</div>
{#if $rooms.includes(url)}
{#if $userSpaceUrls.includes(url)}
<div
class="tip absolute -right-1 -top-1 h-5 w-5 rounded-full bg-primary text-primary-content"
data-tip="You are already a member of this space.">

View file

@ -465,7 +465,6 @@
cleanup?.()
unsubscribeActive()
cancelAnimationFrame(frame)
document.removeEventListener("visibilitychange", onVisibilityChange)
}
})
</script>

View file

@ -55,7 +55,15 @@
const currentPubkey = user.get().pubkey
if (currentPubkey) {
await $roomLists.load(currentPubkey, [url])
// Force a fresh fetch rather than `load`, which can resolve immediately from an
// hour-stale cache and make a space the user has since joined look unjoined.
// Unlike `load`, `forceLoad` doesn't swallow fetch errors, so catch them here —
// otherwise a failed fetch would leave spacesLoaded false forever.
try {
await $roomLists.forceLoad(currentPubkey, [url])
} catch (error) {
console.warn(`Failed to load room list for ${currentPubkey}`, error)
}
}
spacesLoaded = true