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

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