impr: add autofill autosubmit, show URL field always
This commit is contained in:
4 files changed
+42
-22
No files matched your search
@@ -151,7 +151,8 @@
|
|||||||
"normal": "Discussion",
|
"normal": "Discussion",
|
||||||
"poll": "Poll",
|
"poll": "Poll",
|
||||||
"event": "Event"
|
"event": "Event"
|
||||||
}
|
},
|
||||||
|
"autosubmit": "Submit automatically"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"displayName": "Display name",
|
"displayName": "Display name",
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ interface Settings {
|
|||||||
reverseActions: boolean
|
reverseActions: boolean
|
||||||
titleOpensUrl: boolean
|
titleOpensUrl: boolean
|
||||||
}
|
}
|
||||||
|
forms: {
|
||||||
|
autosubmitAutofill: boolean
|
||||||
|
}
|
||||||
infiniteScroll: boolean
|
infiniteScroll: boolean
|
||||||
language: string | null
|
language: string | null
|
||||||
useRtl: boolean
|
useRtl: boolean
|
||||||
@@ -103,7 +106,7 @@ interface Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const defaultSettings: Settings = {
|
export const defaultSettings: Settings = {
|
||||||
settingsVer: 6,
|
settingsVer: 7,
|
||||||
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
|
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
|
||||||
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
|
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
|
||||||
showInstances: {
|
showInstances: {
|
||||||
@@ -169,6 +172,9 @@ export const defaultSettings: Settings = {
|
|||||||
reverseActions: toBool(env.PUBLIC_REVERSE_ACTIONS) ?? false,
|
reverseActions: toBool(env.PUBLIC_REVERSE_ACTIONS) ?? false,
|
||||||
titleOpensUrl: toBool(env.PUBLIC_TITLE_OPENS_URL) ?? false,
|
titleOpensUrl: toBool(env.PUBLIC_TITLE_OPENS_URL) ?? false,
|
||||||
},
|
},
|
||||||
|
forms: {
|
||||||
|
autosubmitAutofill: false,
|
||||||
|
},
|
||||||
infiniteScroll: true,
|
infiniteScroll: true,
|
||||||
language: env.PUBLIC_LANGUAGE ?? null,
|
language: env.PUBLIC_LANGUAGE ?? null,
|
||||||
useRtl: false,
|
useRtl: false,
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
Check,
|
Check,
|
||||||
Icon,
|
Icon,
|
||||||
Language,
|
Language,
|
||||||
Link,
|
|
||||||
Photo,
|
Photo,
|
||||||
Plus,
|
Plus,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
@@ -71,6 +70,20 @@
|
|||||||
|
|
||||||
let loading = $state<boolean>(false)
|
let loading = $state<boolean>(false)
|
||||||
let uploadImage = $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
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if client() instanceof PiefedClient && !editPost}
|
{#if client() instanceof PiefedClient && !editPost}
|
||||||
@@ -137,16 +150,23 @@
|
|||||||
{#snippet autofillPostModal()}
|
{#snippet autofillPostModal()}
|
||||||
<svelte:boundary>
|
<svelte:boundary>
|
||||||
{#if form.url}
|
{#if form.url}
|
||||||
{#await autofillPost(new URL(form.url))}
|
{#await autofill(new URL(form.url))}
|
||||||
<div class="w-full h-64 grid place-items-center">
|
<div class="w-full h-48 grid place-items-center">
|
||||||
<TextLoader>
|
<TextLoader>
|
||||||
{$t('form.post.fetching')}
|
{$t('form.post.fetching')}
|
||||||
</TextLoader>
|
</TextLoader>
|
||||||
</div>
|
</div>
|
||||||
|
<Button size="lg" color="secondary" onclick={history.back}>
|
||||||
|
{$t('common.cancel')}
|
||||||
|
</Button>
|
||||||
{:then url}
|
{:then url}
|
||||||
<Material color="info" class="space-y-2">
|
{#if !url}
|
||||||
|
<!--cursed svelte template abuse. don't do this lads-->
|
||||||
|
{history.back()}
|
||||||
|
{/if}
|
||||||
|
<Material color="info" class="space-y-2 h-48">
|
||||||
<h2 class="text-xl font-display font-medium">{url.title}</h2>
|
<h2 class="text-xl font-display font-medium">{url.title}</h2>
|
||||||
<p>{url.body ?? '...'}</p>
|
<p class="overflow-hidden text-ellipsis">{url.body ?? '...'}</p>
|
||||||
</Material>
|
</Material>
|
||||||
<Button
|
<Button
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -162,6 +182,9 @@
|
|||||||
{:catch err}
|
{:catch err}
|
||||||
<ErrorContainer scope="-1" message={err} />
|
<ErrorContainer scope="-1" message={err} />
|
||||||
{/await}
|
{/await}
|
||||||
|
<Switch class="mt-4" bind:checked={settings.forms.autosubmitAutofill}>
|
||||||
|
{$t('form.post.autosubmit')}
|
||||||
|
</Switch>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:boundary>
|
</svelte:boundary>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
@@ -241,7 +264,7 @@
|
|||||||
previewButton
|
previewButton
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if form.type == 'normal' && form.url !== undefined}
|
{#if form.type == 'normal'}
|
||||||
<TextInput
|
<TextInput
|
||||||
label={$t('form.post.url')}
|
label={$t('form.post.url')}
|
||||||
bind:value={form.url}
|
bind:value={form.url}
|
||||||
@@ -355,13 +378,6 @@
|
|||||||
class="flex flex-row flex-wrap w-full"
|
class="flex flex-row flex-wrap w-full"
|
||||||
>
|
>
|
||||||
{#if form.type == 'normal'}
|
{#if form.type == 'normal'}
|
||||||
<Button
|
|
||||||
onclick={() => (form.url = '')}
|
|
||||||
disabled={form.url !== undefined}
|
|
||||||
icon={Link}
|
|
||||||
>
|
|
||||||
{$t('form.post.addUrl')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
uploadImage = !uploadImage
|
uploadImage = !uploadImage
|
||||||
@@ -383,11 +399,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if form.language === undefined}
|
{#if form.language === undefined}
|
||||||
<Button
|
<Button onclick={() => (form.language = '')} icon={Language}>
|
||||||
class="animate-pop-in"
|
|
||||||
onclick={() => (form.language = '')}
|
|
||||||
icon={Language}
|
|
||||||
>
|
|
||||||
{$t('form.post.setLanguage')}
|
{$t('form.post.setLanguage')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
@variant md {
|
@variant md {
|
||||||
height: calc(var(--spacing) * 8);
|
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);
|
color: var(--color-slate-500);
|
||||||
|
|
||||||
@@ -126,7 +126,8 @@
|
|||||||
.nav-btn-dynamic {
|
.nav-btn-dynamic {
|
||||||
@variant md {
|
@variant md {
|
||||||
width: max-content;
|
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 {
|
@variant hover {
|
||||||
background-color: --alpha(var(--color-slate-200) / 50%);
|
background-color: --alpha(var(--color-slate-200) / 50%);
|
||||||
|
|||||||
Reference in new issue
Block a user