Fix/spurious relay membership prompt (#340)
Co-authored-by: Aditya Chaudhary <30+useradityaa@noreply.coracle.social>
This commit is contained in:
parent
8243f4d245
commit
c8d003524b
3 changed files with 11 additions and 5 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
import RelayDescription from "@app/components/RelayDescription.svelte"
|
import RelayDescription from "@app/components/RelayDescription.svelte"
|
||||||
import ProfileCircles from "@app/components/ProfileCircles.svelte"
|
import ProfileCircles from "@app/components/ProfileCircles.svelte"
|
||||||
import {roomLists, user} from "@app/core"
|
import {roomLists, user} from "@app/core"
|
||||||
import {deriveUserRooms} from "@app/rooms"
|
import {userSpaceUrls} from "@app/rooms"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
url: string
|
url: string
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const {url, hideFavorites}: Props = $props()
|
const {url, hideFavorites}: Props = $props()
|
||||||
const rooms = deriveUserRooms(url)
|
|
||||||
const favorited = $roomLists.pubkeysForUrl(url).$
|
const favorited = $roomLists.pubkeysForUrl(url).$
|
||||||
const favoritedPubkeys = $derived(remove($user.pubkey, $favorited))
|
const favoritedPubkeys = $derived(remove($user.pubkey, $favorited))
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -30,7 +29,7 @@
|
||||||
<RelayIcon {url} size={10} class="rounded-full" />
|
<RelayIcon {url} size={10} class="rounded-full" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if $rooms.includes(url)}
|
{#if $userSpaceUrls.includes(url)}
|
||||||
<div
|
<div
|
||||||
class="tip absolute -right-1 -top-1 h-5 w-5 rounded-full bg-primary text-primary-content"
|
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.">
|
data-tip="You are already a member of this space.">
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,6 @@
|
||||||
cleanup?.()
|
cleanup?.()
|
||||||
unsubscribeActive()
|
unsubscribeActive()
|
||||||
cancelAnimationFrame(frame)
|
cancelAnimationFrame(frame)
|
||||||
document.removeEventListener("visibilitychange", onVisibilityChange)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,15 @@
|
||||||
const currentPubkey = user.get().pubkey
|
const currentPubkey = user.get().pubkey
|
||||||
|
|
||||||
if (currentPubkey) {
|
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
|
spacesLoaded = true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue