update project shortener add/edit form to update data properly

pull/3/head
TZGyn 2 years ago
parent 39ed417ebd
commit e686806887
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -40,8 +40,6 @@
let previewData: any let previewData: any
let isPreviewLoading: boolean = false let isPreviewLoading: boolean = false
$: $formData.link && getMetadata()
const getMetadata = async () => { const getMetadata = async () => {
isPreviewLoading = true isPreviewLoading = true
clearTimeout(inputTimer) clearTimeout(inputTimer)
@ -105,7 +103,8 @@
<Input <Input
{...attrs} {...attrs}
bind:value={$formData.link} bind:value={$formData.link}
placeholder="https://example.com" /> placeholder="https://example.com"
on:input={getMetadata} />
</Form.Control> </Form.Control>
<Form.Description>Shortener link</Form.Description> <Form.Description>Shortener link</Form.Description>
<Form.FieldErrors /> <Form.FieldErrors />

@ -12,7 +12,7 @@
import { toast } from 'svelte-sonner' import { toast } from 'svelte-sonner'
import { Loader2, LoaderCircle } from 'lucide-svelte' import { Loader2, LoaderCircle } from 'lucide-svelte'
import { Checkbox } from '$lib/components/ui/checkbox' import { Checkbox } from '$lib/components/ui/checkbox'
import { browser } from '$app/environment' import { onMount } from 'svelte'
export let data: SuperValidated<Infer<FormSchema>> export let data: SuperValidated<Infer<FormSchema>>
@ -36,8 +36,6 @@
let previewData: any let previewData: any
let isPreviewLoading: boolean = false let isPreviewLoading: boolean = false
$: $formData.link && browser && getMetadata()
const getMetadata = async () => { const getMetadata = async () => {
isPreviewLoading = true isPreviewLoading = true
clearTimeout(inputTimer) clearTimeout(inputTimer)
@ -53,6 +51,10 @@
console.log(previewData) console.log(previewData)
}, 1000) }, 1000)
} }
onMount(() => {
getMetadata()
})
</script> </script>
<div class="grid grid-cols-4 gap-4 items-center pb-4"> <div class="grid grid-cols-4 gap-4 items-center pb-4">
@ -83,7 +85,8 @@
<Input <Input
{...attrs} {...attrs}
bind:value={$formData.link} bind:value={$formData.link}
placeholder="https://example.com" /> placeholder="https://example.com"
on:input={getMetadata} />
</Form.Control> </Form.Control>
<Form.Description>Shortener link</Form.Description> <Form.Description>Shortener link</Form.Description>
<Form.FieldErrors /> <Form.FieldErrors />

@ -20,6 +20,7 @@ export const load = (async (event) => {
android: true, android: true,
android_link: true, android_link: true,
link: true, link: true,
active: true,
}, },
where: (shortener, { eq, and }) => where: (shortener, { eq, and }) =>
and( and(

Loading…
Cancel
Save