fix: add post flair editing
This commit is contained in:
1 parent
46c47b5977
commit
97469f9a3e
4 files changed
+24
-14
No files matched your search
@@ -66,6 +66,15 @@
|
|||||||
post = e
|
post = e
|
||||||
onedit?.(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()}
|
{#snippet formtitle()}
|
||||||
<!-- Have the title not exist at all -->
|
<!-- Have the title not exist at all -->
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
passedData?: {
|
passedData?: {
|
||||||
community: CommunityView | null
|
community: CommunityView | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body?: string
|
||||||
image: FileList | null
|
image: FileList | null
|
||||||
thumbnail?: string
|
thumbnail?: string
|
||||||
url?: string
|
url?: string
|
||||||
@@ -105,6 +105,12 @@
|
|||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (editingPost) Object.assign(data, editingPost)
|
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) {
|
if (passedCommunity) {
|
||||||
data.community = passedCommunity
|
data.community = passedCommunity
|
||||||
communitySearch = passedCommunity.community.name
|
communitySearch = passedCommunity.community.name
|
||||||
@@ -174,14 +180,12 @@
|
|||||||
saveDraft = false
|
saveDraft = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.flair_list.length > 0) {
|
const piefed = client()
|
||||||
const piefed = client()
|
if (piefed.assignFlair) {
|
||||||
if (piefed.assignFlair) {
|
await piefed.assignFlair({
|
||||||
await piefed.assignFlair({
|
flair_id_list: data.flair_list,
|
||||||
flair_id_list: data.flair_list,
|
post_id: post.post_view.post.id,
|
||||||
post_id: post.post_view.post.id,
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onsubmit?.(post.post_view)
|
onsubmit?.(post.post_view)
|
||||||
@@ -245,10 +249,6 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
generation.generatable = canGenerateTitle(data.url)
|
generation.generatable = canGenerateTitle(data.url)
|
||||||
})
|
})
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (data.community) data.flair_list = []
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if uploadingImage}
|
{#if uploadingImage}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ interface SessionStorage {
|
|||||||
postDraft?: {
|
postDraft?: {
|
||||||
community: CommunityView | null
|
community: CommunityView | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body?: string
|
||||||
image: FileList | null
|
image: FileList | null
|
||||||
url?: string
|
url?: string
|
||||||
nsfw: boolean
|
nsfw: boolean
|
||||||
|
|||||||
@@ -85,6 +85,7 @@
|
|||||||
color: i.background_color,
|
color: i.background_color,
|
||||||
icon: null,
|
icon: null,
|
||||||
textColor: i.text_color,
|
textColor: i.text_color,
|
||||||
|
type: 'flair' as 'flair' | 'custom',
|
||||||
})) ?? []),
|
})) ?? []),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user