fix:"Create Invite" shows wrong error message when offline

This commit is contained in:
2026-04-17 20:00:52 +05:30
parent 6977afbfa0
commit a4b35d9774
+15 -3
View File
@@ -26,7 +26,14 @@
const authError = deriveRelayAuthError(url)
let networkError = $state(false)
const isExplicitAuthError = $derived($authError && !($authError.toLowerCase().includes("failed") || $authError.toLowerCase().includes("timeout") || $authError.toLowerCase().includes("network")))
const isExplicitAuthError = $derived(
$authError &&
!(
$authError.toLowerCase().includes("failed") ||
$authError.toLowerCase().includes("timeout") ||
$authError.toLowerCase().includes("network")
),
)
const isGenericError = $derived(networkError || ($authError && !isExplicitAuthError))
const back = () => history.back()
@@ -75,7 +82,10 @@
claim = getTagValue("claim", event?.tags || []) || ""
} catch (err) {
claim = ""
if ((err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError")) || !navigator.onLine) {
if (
(err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError")) ||
!navigator.onLine
) {
networkError = true
}
} finally {
@@ -99,7 +109,9 @@
<Spinner {loading}>Requesting an invite link...</Spinner>
</p>
{:else if isGenericError}
<p class="center text-center">Unable to reach the relay. Please check your connection and try again.</p>
<p class="center text-center">
Unable to reach the relay. Please check your connection and try again.
</p>
{:else if isExplicitAuthError}
<p class="center">Oops! It looks like you're not a member of this relay.</p>
{:else}