fix: add post flair editing

This commit is contained in:
Xylight authored and xylight committed 2025-09-17 00:27:11 +00:00
1 parent 46c47b5977
commit 97469f9a3e
4 files changed
+24 -14

No files matched your search

@@ -66,6 +66,15 @@
post = e
onedit?.(e)
}}
passedData={{
body: post.post.body,
title: post.post.name,
community: null,
flair_list: post.flair_list?.map((i) => i.id) ?? [],
image: null,
loading: false,
nsfw: post.post.nsfw,
}}
>
{#snippet formtitle()}
<!-- Have the title not exist at all -->
@@ -61,7 +61,7 @@
passedData?: {
community: CommunityView | null
title: string
body: string
body?: string
image: FileList | null
thumbnail?: string
url?: string
@@ -105,6 +105,12 @@
onMount(async () => {
if (editingPost) Object.assign(data, editingPost)
if (editingPost?.community_id && !data.community) {
data.community = (
await client().getCommunity({ id: editingPost.community_id })
).community_view
}
if (passedCommunity) {
data.community = passedCommunity
communitySearch = passedCommunity.community.name
@@ -174,14 +180,12 @@
saveDraft = false
}
if (data.flair_list.length > 0) {
const piefed = client()
if (piefed.assignFlair) {
await piefed.assignFlair({
flair_id_list: data.flair_list,
post_id: post.post_view.post.id,
})
}
const piefed = client()
if (piefed.assignFlair) {
await piefed.assignFlair({
flair_id_list: data.flair_list,
post_id: post.post_view.post.id,
})
}
onsubmit?.(post.post_view)
@@ -245,10 +249,6 @@
$effect(() => {
generation.generatable = canGenerateTitle(data.url)
})
$effect(() => {
if (data.community) data.flair_list = []
})
</script>
{#if uploadingImage}
+1 -1
View File
@@ -6,7 +6,7 @@ interface SessionStorage {
postDraft?: {
community: CommunityView | null
title: string
body: string
body?: string
image: FileList | null
url?: string
nsfw: boolean