fix: show deep-link action errors with abort-or-continue flow
This commit is contained in:
@@ -79,6 +79,7 @@
|
||||
const hasShare = !!shareRelay && !!shareH
|
||||
|
||||
let processing = $state(false)
|
||||
let errors = $state<string[]>([])
|
||||
|
||||
onMount(() => {
|
||||
if (!hasSettings) {
|
||||
@@ -99,6 +100,10 @@
|
||||
|
||||
const accept = async () => {
|
||||
processing = true
|
||||
errors = []
|
||||
|
||||
const nextErrors: string[] = []
|
||||
|
||||
try {
|
||||
if (t) {
|
||||
theme.set(t)
|
||||
@@ -106,8 +111,16 @@
|
||||
|
||||
if (relays.length > 0) {
|
||||
for (const url of relays) {
|
||||
addRelay(url, RelayMode.Read)
|
||||
addRelay(url, RelayMode.Write)
|
||||
const readError = await waitForThunkError(await addRelay(url, RelayMode.Read))
|
||||
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) {
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: `Failed to update blossom servers: ${errorMessage(error)}`,
|
||||
})
|
||||
return
|
||||
nextErrors.push(`Blossom servers: ${errorMessage(error)}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,14 +150,17 @@
|
||||
)
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: `Failed to update follows: ${errorMessage(error)}`})
|
||||
return
|
||||
nextErrors.push(`Follows: ${errorMessage(error)}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (joins.length > 0) {
|
||||
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}))
|
||||
|
||||
if (error) {
|
||||
if (error.includes("rate-limited") || error.startsWith("blocked:")) {
|
||||
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
|
||||
}
|
||||
nextErrors.push(`Profile: ${errorMessage(error)}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (nextErrors.length > 0) {
|
||||
errors = nextErrors
|
||||
return
|
||||
}
|
||||
|
||||
pushToast({message: "Customizations Applied!"})
|
||||
|
||||
if (hasShare) {
|
||||
@@ -186,6 +196,16 @@
|
||||
processing = false
|
||||
}
|
||||
}
|
||||
|
||||
const continueWithErrors = async () => {
|
||||
pushToast({message: "Applied what we could. Some actions failed."})
|
||||
|
||||
if (hasShare) {
|
||||
await openShare()
|
||||
} else {
|
||||
back()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if hasSettings}
|
||||
@@ -199,40 +219,54 @@
|
||||
</ModalHeader>
|
||||
|
||||
<ModalBody>
|
||||
<p>This link will apply the following changes:</p>
|
||||
<ul class="text-left list-disc list-inside px-6 py-4">
|
||||
{#if t}
|
||||
<li>Set theme to "{t}"</li>
|
||||
{/if}
|
||||
{#if relays.length > 0}
|
||||
<li>Add {relays.length} relay{relays.length > 1 ? "s" : ""} to your settings</li>
|
||||
{/if}
|
||||
{#if blossoms.length > 0}
|
||||
<li>Add {blossoms.length} blossom server{blossoms.length > 1 ? "s" : ""}</li>
|
||||
{/if}
|
||||
{#if follows.length > 0}
|
||||
<li>Follow {follows.length} person{follows.length > 1 ? "s" : ""}</li>
|
||||
{/if}
|
||||
{#if joins.length > 0}
|
||||
<li>Join {joins.length} communit{joins.length > 1 ? "ies" : "y"}</li>
|
||||
{/if}
|
||||
{#if hasProfile}
|
||||
<li>Update your profile metadata</li>
|
||||
{/if}
|
||||
{#if hasShare}
|
||||
<li>Open a new post dialog in a specific room</li>
|
||||
{/if}
|
||||
</ul>
|
||||
{#if errors.length === 0}
|
||||
<p>This link will apply the following changes:</p>
|
||||
<ul class="text-left list-disc list-inside px-6 py-4">
|
||||
{#if t}
|
||||
<li>Set theme to "{t}"</li>
|
||||
{/if}
|
||||
{#if relays.length > 0}
|
||||
<li>Add {relays.length} relay{relays.length > 1 ? "s" : ""} to your settings</li>
|
||||
{/if}
|
||||
{#if blossoms.length > 0}
|
||||
<li>Add {blossoms.length} blossom server{blossoms.length > 1 ? "s" : ""}</li>
|
||||
{/if}
|
||||
{#if follows.length > 0}
|
||||
<li>Follow {follows.length} person{follows.length > 1 ? "s" : ""}</li>
|
||||
{/if}
|
||||
{#if joins.length > 0}
|
||||
<li>Join {joins.length} communit{joins.length > 1 ? "ies" : "y"}</li>
|
||||
{/if}
|
||||
{#if hasProfile}
|
||||
<li>Update your profile metadata</li>
|
||||
{/if}
|
||||
{#if hasShare}
|
||||
<li>Open a new post dialog in a specific room</li>
|
||||
{/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>
|
||||
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-neutral" onclick={back}>Cancel</Button>
|
||||
<Button class="btn btn-primary" onclick={accept} disabled={processing}>
|
||||
{#if processing}
|
||||
<span class="loading loading-spinner"></span>
|
||||
{/if}
|
||||
Accept
|
||||
</Button>
|
||||
{#if errors.length === 0}
|
||||
<Button class="btn btn-neutral" onclick={back}>Cancel</Button>
|
||||
<Button class="btn btn-primary" onclick={accept} disabled={processing}>
|
||||
{#if processing}
|
||||
<span class="loading loading-spinner"></span>
|
||||
{/if}
|
||||
Accept
|
||||
</Button>
|
||||
{:else}
|
||||
<Button class="btn btn-neutral" onclick={back}>Abort</Button>
|
||||
<Button class="btn btn-primary" onclick={continueWithErrors}>Continue</Button>
|
||||
{/if}
|
||||
</ModalFooter>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user