mirror of
https://github.com/elk-zone/elk
synced 2024-11-27 14:28:10 +09:00
fix(ui): generate only one thread composer in PublishWidgetList
and provide it to each widget (#2953)
This commit is contained in:
parent
dbf743afd9
commit
4061075dde
@ -5,6 +5,7 @@ import type { mastodon } from 'masto'
|
|||||||
import type { DraftItem } from '~/types'
|
import type { DraftItem } from '~/types'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
threadComposer,
|
||||||
draftKey,
|
draftKey,
|
||||||
draftItemIndex,
|
draftItemIndex,
|
||||||
expanded = false,
|
expanded = false,
|
||||||
@ -15,6 +16,7 @@ const {
|
|||||||
draftKey: string
|
draftKey: string
|
||||||
draftItemIndex: number
|
draftItemIndex: number
|
||||||
initial?: () => DraftItem
|
initial?: () => DraftItem
|
||||||
|
threadComposer?: ReturnType<typeof useThreadComposer>
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
inReplyToId?: string
|
inReplyToId?: string
|
||||||
inReplyToVisibility?: mastodon.v1.StatusVisibility
|
inReplyToVisibility?: mastodon.v1.StatusVisibility
|
||||||
@ -28,7 +30,7 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const { threadItems, threadIsActive, publishThread } = useThreadComposer(draftKey)
|
const { threadItems, threadIsActive, publishThread } = threadComposer ?? useThreadComposer(draftKey)
|
||||||
|
|
||||||
const draft = computed({
|
const draft = computed({
|
||||||
get: () => threadItems.value[draftItemIndex],
|
get: () => threadItems.value[draftItemIndex],
|
||||||
|
@ -20,9 +20,8 @@ const {
|
|||||||
dialogLabelledBy?: string
|
dialogLabelledBy?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const threadItems = computed(() =>
|
const threadComposer = useThreadComposer(draftKey, initial)
|
||||||
useThreadComposer(draftKey, initial).threadItems.value,
|
const threadItems = computed(() => threadComposer.threadItems.value)
|
||||||
)
|
|
||||||
|
|
||||||
onDeactivated(() => {
|
onDeactivated(() => {
|
||||||
clearEmptyDrafts()
|
clearEmptyDrafts()
|
||||||
@ -38,6 +37,7 @@ function isFirstItem(index: number) {
|
|||||||
<PublishWidget
|
<PublishWidget
|
||||||
v-for="(_, index) in threadItems" :key="`${draftKey}-${index}`"
|
v-for="(_, index) in threadItems" :key="`${draftKey}-${index}`"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
:thread-composer="threadComposer"
|
||||||
:draft-key="draftKey"
|
:draft-key="draftKey"
|
||||||
:draft-item-index="index"
|
:draft-item-index="index"
|
||||||
:expanded="isFirstItem(index) ? expanded : true"
|
:expanded="isFirstItem(index) ? expanded : true"
|
||||||
|
Loading…
Reference in New Issue
Block a user