{#if profile.client instanceof PiefedClient && !editPost}
{/if} {#if uploadImage}
'', (v) => (form.url = v)} /> {/if} {#if customThumbnail}
form.thumbnail, (v) => (form.thumbnail = v)} /> {/if} {#snippet altText()}
{/snippet} {#snippet flairs()}
{#await extendedCommunity}
{:then communityView} {#each communityView?.community_view.flair_list ?? [] as flair} {@const selected = form.flairList?.some((i) => i.id == flair.id)}
{ if (selected) { const index = form.flairList.findIndex((i) => i.id == flair.id) if (index != -1) form.flairList.splice(index, 1) } else form.flairList.push(flair) }} >
{#snippet icon()}
{/snippet} {flair.flair_title}
{/each} {/await}
{/snippet} {#snippet autofillPostModal()}
{#if form.url} {#await autofill(new URL(form.url))}
{$t('form.post.fetching')}
{$t('common.cancel')}
{:then url} {#if !url} {history.back()} {/if}
{url.title}
{url.body ?? '...'}
{ autofill({ title: url.title, body: url.body }) history.back() }} > {$t('form.submit')}
{:catch err}
{/await}
{$t('form.post.autosubmit')}
{/if}
{/snippet}
{ e.preventDefault() loading = true form .submit(editPost) .then(onsubmit) .catch((err) => pushError({ message: errorMessage(err as string), scope: 'post-form' }), ) .then(() => (loading = false)) }} class="flex flex-col gap-4 h-full" > {#if title} {@render title()} {:else}
{editPost ? $t('form.post.edit') : $t('form.post.create')}
{/if}
{#if !editPost} {#if !form.community}
{ form.community = i.community }} required /> {:else}
{$t('form.post.community')}
(form.community = undefined)} alignment="left" size="sm" rounding="xl" > {#snippet prefix()}
{/snippet}
{form.community.name}
{new URL(form.community?.actor_id).hostname}
{/if} {/if}
{#if form.type == 'normal'}
{#snippet suffix()}
modal({ title: $t('form.post.generateTitle'), snippet: autofillPostModal, actions: [], })} /> {/snippet}
{/if} {#if form.type == 'poll' && form.poll}
{$t('post.poll.choices')}
{#each form.poll.choices as _, index}
form.poll?.choices.splice(index, 1)} size="square-md" aria-label={$t('post.actions.more.delete')} >
{/each}
form.poll?.choices.push({ choice_text: `Option ${form.poll?.choices.length + 1}`, id: Math.max(...form.poll.choices.map((i) => i.id)) + 1, num_votes: 0, sort_order: 2, })} type="button" class="font-medium w-full px-4 py-2! flex flex-row items-center gap-1 justify-center cursor-pointer" >
{$t('common.add')}
{$t('post.poll.single')}
{$t('post.poll.multiple')}
{#snippet action()} {#if !editPost}
{ return form.poll?.end_poll ? Math.floor( Date.now() - publishedToDate(form.poll?.end_poll).getTime(), ) : Date.now() + 24 * 60 * 60 }, (v) => { if (v <= 0) form.poll!.end_poll = undefined else form.poll!.end_poll = new Date( Date.now() + v * 1000, ).toISOString() } } /> {/if} {/snippet}
{#if settings.debugInfo} {form.poll?.end_poll} {/if} {/if}
{#if form.type == 'normal'}
{ uploadImage = !uploadImage }} icon={Photo} > {$t('form.post.uploadImage')}
{#if form.url && URL.canParse(form.url)}
modal({ title: $t('form.post.altText'), snippet: altText })} icon={ChatBubbleBottomCenterText} > {$t('form.post.altText')}
{/if} {#if form.url}
{ customThumbnail = !customThumbnail }} color={form.thumbnail ? 'primary' : 'secondary'} icon={QrCode} > {$t('form.post.customThumbnail')}
{/if} {/if} {#if form.language === undefined}
(form.language = '')} icon={Language}> {$t('form.post.setLanguage')}
{/if} {#await extendedCommunity then communityView} {#if (communityView?.community_view.flair_list?.length || 0) > 0}
0 ? 'primary' : 'secondary'} class="animate-pop-in" onclick={() => modal({ title: $t('form.post.flair'), snippet: flairs })} icon={Tag} > {$t('form.post.flair')}
{/if} {/await}
{#if form.language !== undefined} {#if site.data}
form.language, (v) => { if (v == '') form.language = undefined else form.language = v } } >
{$t('form.post.unset')}
{#each site.data?.all_languages as language}
{language.name}
{/each}
{:else}
{/if} {/if}
{$t('form.post.nsfw')}
{$t('form.submit')}