2024-04-08 09:53:26 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { mastodon } from 'masto'
|
|
|
|
import type { DraftItem } from '~/types'
|
|
|
|
|
|
|
|
const {
|
|
|
|
draftKey,
|
|
|
|
initial = getDefaultDraftItem,
|
|
|
|
expanded = false,
|
|
|
|
placeholder,
|
|
|
|
dialogLabelledBy,
|
|
|
|
inReplyToId,
|
|
|
|
inReplyToVisibility,
|
|
|
|
} = defineProps<{
|
|
|
|
draftKey: string
|
|
|
|
initial?: () => DraftItem
|
|
|
|
placeholder?: string
|
|
|
|
inReplyToId?: string
|
|
|
|
inReplyToVisibility?: mastodon.v1.StatusVisibility
|
|
|
|
expanded?: boolean
|
|
|
|
dialogLabelledBy?: string
|
|
|
|
}>()
|
|
|
|
|
2024-09-11 20:37:14 +00:00
|
|
|
const threadComposer = useThreadComposer(draftKey, initial)
|
|
|
|
const threadItems = computed(() => threadComposer.threadItems.value)
|
2024-04-08 09:53:26 +00:00
|
|
|
|
|
|
|
onDeactivated(() => {
|
|
|
|
clearEmptyDrafts()
|
|
|
|
})
|
|
|
|
|
|
|
|
function isFirstItem(index: number) {
|
|
|
|
return index === 0
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template v-if="isHydrated && currentUser">
|
|
|
|
<PublishWidget
|
|
|
|
v-for="(_, index) in threadItems" :key="`${draftKey}-${index}`"
|
2024-09-11 15:43:30 +00:00
|
|
|
v-bind="$attrs"
|
2024-09-11 20:37:14 +00:00
|
|
|
:thread-composer="threadComposer"
|
2024-04-08 09:53:26 +00:00
|
|
|
:draft-key="draftKey"
|
|
|
|
:draft-item-index="index"
|
|
|
|
:expanded="isFirstItem(index) ? expanded : true"
|
|
|
|
:placeholder="placeholder"
|
|
|
|
:dialog-labelled-by="dialogLabelledBy"
|
|
|
|
:in-reply-to-id="isFirstItem(index) ? inReplyToId : undefined"
|
|
|
|
:in-reply-to-visibility="inReplyToVisibility"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</template>
|