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

This commit is contained in:
deveshanim3
2026-04-17 20:00:52 +05:30
parent 6977afbfa0
commit a4b35d9774
+15 -3
View File
@@ -26,7 +26,14 @@
const authError = deriveRelayAuthError(url) const authError = deriveRelayAuthError(url)
let networkError = $state(false) 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 isGenericError = $derived(networkError || ($authError && !isExplicitAuthError))
const back = () => history.back() const back = () => history.back()
@@ -75,7 +82,10 @@
claim = getTagValue("claim", event?.tags || []) || "" claim = getTagValue("claim", event?.tags || []) || ""
} catch (err) { } catch (err) {
claim = "" 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 networkError = true
} }
} finally { } finally {
@@ -99,7 +109,9 @@
<Spinner {loading}>Requesting an invite link...</Spinner> <Spinner {loading}>Requesting an invite link...</Spinner>
</p> </p>
{:else if isGenericError} {: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} {:else if isExplicitAuthError}
<p class="center">Oops! It looks like you're not a member of this relay.</p> <p class="center">Oops! It looks like you're not a member of this relay.</p>
{:else} {:else}