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
+52 -18
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,16 +176,14 @@
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 { if (nextErrors.length > 0) {
pushToast({theme: "error", message: `Failed to update profile: ${errorMessage(error)}`}) errors = nextErrors
return return
} }
}
}
pushToast({message: "Customizations Applied!"}) pushToast({message: "Customizations Applied!"})
@@ -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,6 +219,7 @@
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
{#if errors.length === 0}
<p>This link will apply the following changes:</p> <p>This link will apply the following changes:</p>
<ul class="text-left list-disc list-inside px-6 py-4"> <ul class="text-left list-disc list-inside px-6 py-4">
{#if t} {#if t}
@@ -223,9 +244,18 @@
<li>Open a new post dialog in a specific room</li> <li>Open a new post dialog in a specific room</li>
{/if} {/if}
</ul> </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>
{#if errors.length === 0}
<Button class="btn btn-neutral" onclick={back}>Cancel</Button> <Button class="btn btn-neutral" onclick={back}>Cancel</Button>
<Button class="btn btn-primary" onclick={accept} disabled={processing}> <Button class="btn btn-primary" onclick={accept} disabled={processing}>
{#if processing} {#if processing}
@@ -233,6 +263,10 @@
{/if} {/if}
Accept Accept
</Button> </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>