From 22bdfc8ae9f133624c1bfeff8c435065842d71b9 Mon Sep 17 00:00:00 2001 From: Xylight Date: Fri, 28 Nov 2025 11:20:14 -0800 Subject: [PATCH] impr: add autofill autosubmit, show URL field always --- src/lib/app/i18n/en.json | 3 +- src/lib/app/settings.svelte.ts | 8 +++- src/lib/feature/post/form/PostForm.svelte | 48 ++++++++++++++--------- src/lib/ui/navbar/NavButton.svelte | 5 ++- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/lib/app/i18n/en.json b/src/lib/app/i18n/en.json index 41edcb86..68bf1793 100644 --- a/src/lib/app/i18n/en.json +++ b/src/lib/app/i18n/en.json @@ -151,7 +151,8 @@ "normal": "Discussion", "poll": "Poll", "event": "Event" - } + }, + "autosubmit": "Submit automatically" }, "profile": { "displayName": "Display name", diff --git a/src/lib/app/settings.svelte.ts b/src/lib/app/settings.svelte.ts index 4cb98d11..7aa921a4 100644 --- a/src/lib/app/settings.svelte.ts +++ b/src/lib/app/settings.svelte.ts @@ -89,6 +89,9 @@ interface Settings { reverseActions: boolean titleOpensUrl: boolean } + forms: { + autosubmitAutofill: boolean + } infiniteScroll: boolean language: string | null useRtl: boolean @@ -103,7 +106,7 @@ interface Settings { } export const defaultSettings: Settings = { - settingsVer: 6, + settingsVer: 7, expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true, markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true, showInstances: { @@ -169,6 +172,9 @@ export const defaultSettings: Settings = { reverseActions: toBool(env.PUBLIC_REVERSE_ACTIONS) ?? false, titleOpensUrl: toBool(env.PUBLIC_TITLE_OPENS_URL) ?? false, }, + forms: { + autosubmitAutofill: false, + }, infiniteScroll: true, language: env.PUBLIC_LANGUAGE ?? null, useRtl: false, diff --git a/src/lib/feature/post/form/PostForm.svelte b/src/lib/feature/post/form/PostForm.svelte index a5c4caa7..7944f14a 100644 --- a/src/lib/feature/post/form/PostForm.svelte +++ b/src/lib/feature/post/form/PostForm.svelte @@ -37,7 +37,6 @@ Check, Icon, Language, - Link, Photo, Plus, Sparkles, @@ -71,6 +70,20 @@ let loading = $state(false) let uploadImage = $state(false) + + async function autofill( + url: URL, + ): Promise<{ title?: string; body?: string }> { + const res = await autofillPost(url) + + if (settings.forms.autosubmitAutofill) { + form.title = res.title || form.title + form.body = res.body || form.body + history?.back?.() + } + + return res + } {#if client() instanceof PiefedClient && !editPost} @@ -137,16 +150,23 @@ {#snippet autofillPostModal()} {#if form.url} - {#await autofillPost(new URL(form.url))} -
+ {#await autofill(new URL(form.url))} +
{$t('form.post.fetching')}
+ {:then url} - + {#if !url} + + {history.back()} + {/if} +

{url.title}

-

{url.body ?? '...'}

+

{url.body ?? '...'}

{/if} diff --git a/src/lib/ui/navbar/NavButton.svelte b/src/lib/ui/navbar/NavButton.svelte index 03083d3b..d8b41c6b 100644 --- a/src/lib/ui/navbar/NavButton.svelte +++ b/src/lib/ui/navbar/NavButton.svelte @@ -87,7 +87,7 @@ @variant md { height: calc(var(--spacing) * 8); } - transition: 100ms cubic-bezier(0.075, 0.82, 0.165, 1); + transition: 125ms cubic-bezier(0.075, 0.82, 0.165, 1); color: var(--color-slate-500); @@ -126,7 +126,8 @@ .nav-btn-dynamic { @variant md { width: max-content; - padding: calc(var(--spacing)) calc(var(--spacing) * 3); + height: max-content; + padding: calc(var(--spacing) * 1.25) calc(var(--spacing) * 3); @variant hover { background-color: --alpha(var(--color-slate-200) / 50%);