fix: show deep-link action errors with abort-or-continue flow

This commit is contained in:
Bhavishy
2026-04-07 23:19:20 +05:30
parent 17714253ee
commit 436ced8dd7
+83 -49
View File
@@ -79,6 +79,7 @@
const hasShare = !!shareRelay && !!shareH const hasShare = !!shareRelay && !!shareH
let processing = $state(false) let processing = $state(false)
let errors = $state<string[]>([])
onMount(() => { onMount(() => {
if (!hasSettings) { if (!hasSettings) {
@@ -99,6 +100,10 @@
const accept = async () => { const accept = async () => {
processing = true processing = true
errors = []
const nextErrors: string[] = []
try { try {
if (t) { if (t) {
theme.set(t) theme.set(t)
@@ -106,8 +111,16 @@
if (relays.length > 0) { if (relays.length > 0) {
for (const url of relays) { for (const url of relays) {
addRelay(url, RelayMode.Read) const readError = await waitForThunkError(await addRelay(url, RelayMode.Read))
addRelay(url, RelayMode.Write) const writeError = await waitForThunkError(await addRelay(url, RelayMode.Write))
if (readError) {
nextErrors.push(`Relay ${url} (read): ${errorMessage(readError)}`)
}
if (writeError) {
nextErrors.push(`Relay ${url} (write): ${errorMessage(writeError)}`)
}
} }
} }
@@ -122,11 +135,7 @@
) )
if (error) { if (error) {
pushToast({ nextErrors.push(`Blossom servers: ${errorMessage(error)}`)
theme: "error",
message: `Failed to update blossom servers: ${errorMessage(error)}`,
})
return
} }
} }
@@ -141,14 +150,17 @@
) )
if (error) { if (error) {
pushToast({theme: "error", message: `Failed to update follows: ${errorMessage(error)}`}) nextErrors.push(`Follows: ${errorMessage(error)}`)
return
} }
} }
if (joins.length > 0) { if (joins.length > 0) {
for (const url of joins) { for (const url of joins) {
await addSpaceMembership(url) const error = await waitForThunkError(await addSpaceMembership(url))
if (error) {
nextErrors.push(`Join ${url}: ${errorMessage(error)}`)
}
} }
} }
@@ -164,17 +176,15 @@
const error = await waitForThunkError(updateProfile({profile, shouldBroadcast: true})) const error = await waitForThunkError(updateProfile({profile, shouldBroadcast: true}))
if (error) { if (error) {
if (error.includes("rate-limited") || error.startsWith("blocked:")) { nextErrors.push(`Profile: ${errorMessage(error)}`)
pushToast({
message: "Profile update was requested, but one relay rate-limited or blocked it.",
})
} else {
pushToast({theme: "error", message: `Failed to update profile: ${errorMessage(error)}`})
return
}
} }
} }
if (nextErrors.length > 0) {
errors = nextErrors
return
}
pushToast({message: "Customizations Applied!"}) pushToast({message: "Customizations Applied!"})
if (hasShare) { if (hasShare) {
@@ -186,6 +196,16 @@
processing = false processing = false
} }
} }
const continueWithErrors = async () => {
pushToast({message: "Applied what we could. Some actions failed."})
if (hasShare) {
await openShare()
} else {
back()
}
}
</script> </script>
{#if hasSettings} {#if hasSettings}
@@ -199,40 +219,54 @@
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
<p>This link will apply the following changes:</p> {#if errors.length === 0}
<ul class="text-left list-disc list-inside px-6 py-4"> <p>This link will apply the following changes:</p>
{#if t} <ul class="text-left list-disc list-inside px-6 py-4">
<li>Set theme to "{t}"</li> {#if t}
{/if} <li>Set theme to "{t}"</li>
{#if relays.length > 0} {/if}
<li>Add {relays.length} relay{relays.length > 1 ? "s" : ""} to your settings</li> {#if relays.length > 0}
{/if} <li>Add {relays.length} relay{relays.length > 1 ? "s" : ""} to your settings</li>
{#if blossoms.length > 0} {/if}
<li>Add {blossoms.length} blossom server{blossoms.length > 1 ? "s" : ""}</li> {#if blossoms.length > 0}
{/if} <li>Add {blossoms.length} blossom server{blossoms.length > 1 ? "s" : ""}</li>
{#if follows.length > 0} {/if}
<li>Follow {follows.length} person{follows.length > 1 ? "s" : ""}</li> {#if follows.length > 0}
{/if} <li>Follow {follows.length} person{follows.length > 1 ? "s" : ""}</li>
{#if joins.length > 0} {/if}
<li>Join {joins.length} communit{joins.length > 1 ? "ies" : "y"}</li> {#if joins.length > 0}
{/if} <li>Join {joins.length} communit{joins.length > 1 ? "ies" : "y"}</li>
{#if hasProfile} {/if}
<li>Update your profile metadata</li> {#if hasProfile}
{/if} <li>Update your profile metadata</li>
{#if hasShare} {/if}
<li>Open a new post dialog in a specific room</li> {#if hasShare}
{/if} <li>Open a new post dialog in a specific room</li>
</ul> {/if}
</ul>
{:else}
<p>Some actions failed. You can abort or continue with successful actions only.</p>
<ul class="text-left list-disc list-inside px-6 py-4 text-error">
{#each errors as error}
<li>{error}</li>
{/each}
</ul>
{/if}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button class="btn btn-neutral" onclick={back}>Cancel</Button> {#if errors.length === 0}
<Button class="btn btn-primary" onclick={accept} disabled={processing}> <Button class="btn btn-neutral" onclick={back}>Cancel</Button>
{#if processing} <Button class="btn btn-primary" onclick={accept} disabled={processing}>
<span class="loading loading-spinner"></span> {#if processing}
{/if} <span class="loading loading-spinner"></span>
Accept {/if}
</Button> Accept
</Button>
{:else}
<Button class="btn btn-neutral" onclick={back}>Abort</Button>
<Button class="btn btn-primary" onclick={continueWithErrors}>Continue</Button>
{/if}
</ModalFooter> </ModalFooter>
</div> </div>
</Modal> </Modal>