fix: restore settings scroll and deep-link dialog close behavior

This commit is contained in:
2026-04-07 16:36:40 +05:30
parent a38c30b57f
commit 17714253ee
5 changed files with 141 additions and 104 deletions
+137 -99
View File
@@ -10,6 +10,7 @@
addRelay,
pubkey,
profilesByPubkey,
waitForThunkError,
} from "@welshman/app"
import {
makeEvent,
@@ -29,11 +30,11 @@
import ModalTitle from "@lib/components/ModalTitle.svelte"
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
import Button from "@lib/components/Button.svelte"
import Icon from "@lib/components/Icon.svelte"
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
import {theme} from "@app/util/theme"
import {pushModal} from "@app/util/modal"
import {pushToast} from "@app/util/toast"
import {errorMessage} from "@lib/util"
import Modal from "@lib/components/Modal.svelte"
import ThreadCreate from "@app/components/ThreadCreate.svelte"
import {addSpaceMembership, updateProfile} from "@app/core/commands"
@@ -54,12 +55,20 @@
const profile_about = params.get("profile_about")
const profile_picture = params.get("profile_picture")
const profile_banner = params.get("profile_banner")
const profile_nip05 = params.get("profile_nip05")
const profile_lud16 = params.get("profile_lud16")
const shareRelay = params.get("share_relay") || params.get("share_url")
const shareH = params.get("share_h")
const shareText = params.get("share_text")
const hasProfile = !!profile_name || !!profile_about || !!profile_picture || !!profile_banner
const hasProfile =
!!profile_name ||
!!profile_about ||
!!profile_picture ||
!!profile_banner ||
!!profile_nip05 ||
!!profile_lud16
const hasSettings =
!!t ||
relays.length > 0 ||
@@ -74,7 +83,7 @@
onMount(() => {
if (!hasSettings) {
if (hasShare) {
doShare()
void openShare()
} else {
pushToast({message: "No valid intent actions found", theme: "error"})
back()
@@ -82,120 +91,149 @@
}
})
const doShare = () => {
back()
goto(`/spaces/${encodeURIComponent(shareRelay!)}/${shareH}`).then(() => {
pushModal(ThreadCreate, {url: shareRelay!, h: shareH!, initialContent: shareText || ""})
})
const openShare = async () => {
await goto(`/spaces/${encodeURIComponent(shareRelay!)}/${shareH}`)
pushModal(ThreadCreate, {url: shareRelay!, h: shareH!, initialContent: shareText || ""})
}
const accept = async () => {
processing = true
if (t === "dark" || t === "light" || t === "system") {
theme.set(t)
}
if (relays.length > 0) {
for (const url of relays) {
addRelay(url, RelayMode.Read)
addRelay(url, RelayMode.Write)
try {
if (t) {
theme.set(t)
}
}
if (blossoms.length > 0) {
const current = getTagValues("server", getListTags(get(userBlossomServerList)))
const updated = Array.from(new Set([...current, ...blossoms]))
publishThunk({
event: makeEvent(BLOSSOM_SERVERS, {tags: updated.map(tagger("server"))}),
relays: Router.get().FromUser().getUrls(),
})
}
if (follows.length > 0) {
const current = getPubkeyTagValues(getListTags(get(userFollowList)))
const updated = Array.from(new Set([...current, ...follows]))
publishThunk({
event: makeEvent(FOLLOWS, {tags: updated.map(tagPubkey)}),
relays: Router.get().FromUser().getUrls(),
})
}
if (joins.length > 0) {
for (const url of joins) {
await addSpaceMembership(url)
if (relays.length > 0) {
for (const url of relays) {
addRelay(url, RelayMode.Read)
addRelay(url, RelayMode.Write)
}
}
}
if (hasProfile) {
const p = get(profilesByPubkey).get(get(pubkey)!) || makeProfile()
if (profile_name) p.name = profile_name
if (profile_about) p.about = profile_about
if (profile_picture) p.picture = profile_picture
if (profile_banner) p.banner = profile_banner
// assuming shouldBroadcast makes it public
await updateProfile({profile: p, shouldBroadcast: true})
}
if (blossoms.length > 0) {
const current = getTagValues("server", getListTags(get(userBlossomServerList)))
const updated = Array.from(new Set([...current, ...blossoms]))
const error = await waitForThunkError(
publishThunk({
event: makeEvent(BLOSSOM_SERVERS, {tags: updated.map(tagger("server"))}),
relays: Router.get().FromUser().getUrls(),
}),
)
pushToast({message: "Customizations Applied!"})
if (error) {
pushToast({
theme: "error",
message: `Failed to update blossom servers: ${errorMessage(error)}`,
})
return
}
}
if (hasShare) {
doShare()
} else {
back()
if (follows.length > 0) {
const current = getPubkeyTagValues(getListTags(get(userFollowList)))
const updated = Array.from(new Set([...current, ...follows]))
const error = await waitForThunkError(
publishThunk({
event: makeEvent(FOLLOWS, {tags: updated.map(tagPubkey)}),
relays: Router.get().FromUser().getUrls(),
}),
)
if (error) {
pushToast({theme: "error", message: `Failed to update follows: ${errorMessage(error)}`})
return
}
}
if (joins.length > 0) {
for (const url of joins) {
await addSpaceMembership(url)
}
}
if (hasProfile) {
const profile = {...(get(profilesByPubkey).get(get(pubkey)!) || makeProfile())}
if (profile_name) profile.name = profile_name
if (profile_about) profile.about = profile_about
if (profile_picture) profile.picture = profile_picture
if (profile_banner) profile.banner = profile_banner
if (profile_nip05) profile.nip05 = profile_nip05
if (profile_lud16) profile.lud16 = profile_lud16
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
}
}
}
pushToast({message: "Customizations Applied!"})
if (hasShare) {
await openShare()
} else {
back()
}
} finally {
processing = false
}
}
</script>
{#if hasSettings}
<form class="flex flex-col gap-4 text-center">
<ModalHeader>
<div class="flex items-center gap-2">
<Button class="btn btn-neutral btn-sm" onclick={back}>
<Icon icon={AltArrowLeft} />
</Button>
<Modal tag="form" onsubmit={(event: SubmitEvent) => event.preventDefault()}>
<div class="flex flex-col gap-4 text-center">
<ModalHeader>
<div class="flex flex-col items-start gap-1">
<ModalTitle>Apply Customization?</ModalTitle>
<ModalSubtitle>A link is requesting to customize your app.</ModalSubtitle>
</div>
</div>
</ModalHeader>
</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>
</ModalBody>
<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>
</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>
</ModalFooter>
</form>
<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>
</ModalFooter>
</div>
</Modal>
{/if}
+1 -2
View File
@@ -6,7 +6,6 @@
import Close from "@assets/icons/close.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import {clearModals} from "@app/util/modal"
type Props = {
onClose?: any
@@ -56,7 +55,7 @@
<div class={wrapperClass}>
<div class={innerClass} transition:fly>
{#if !noEscape}
<Button class={buttonClass} onclick={clearModals}>
<Button class={buttonClass} onclick={onClose}>
<Icon icon={Close} size={6} />
</Button>
{/if}
+1 -1
View File
@@ -13,4 +13,4 @@
}
</script>
<Dialog {children} />
<Dialog {children} onClose={() => goto("/home")} />
+1 -1
View File
@@ -13,4 +13,4 @@
}
</script>
<Dialog {children} />
<Dialog {children} onClose={() => goto("/home")} />
+1 -1
View File
@@ -67,6 +67,6 @@
</SecondaryNavSection>
</SecondaryNav>
<Page>
<Page class="scroll-container overflow-y-auto overflow-x-hidden">
{@render children?.()}
</Page>