Skip to content

Commit

Permalink
fix(ui): generate only one thread composer in PublishWidgetList and…
Browse files Browse the repository at this point in the history
… provide it to each widget (#2953)
  • Loading branch information
userquin authored Sep 11, 2024
1 parent dbf743a commit 4061075
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion components/publish/PublishWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { mastodon } from 'masto'
import type { DraftItem } from '~/types'
const {
threadComposer,
draftKey,
draftItemIndex,
expanded = false,
Expand All @@ -15,6 +16,7 @@ const {
draftKey: string
draftItemIndex: number
initial?: () => DraftItem
threadComposer?: ReturnType<typeof useThreadComposer>
placeholder?: string
inReplyToId?: string
inReplyToVisibility?: mastodon.v1.StatusVisibility
Expand All @@ -28,7 +30,7 @@ const emit = defineEmits<{
const { t } = useI18n()
const { threadItems, threadIsActive, publishThread } = useThreadComposer(draftKey)
const { threadItems, threadIsActive, publishThread } = threadComposer ?? useThreadComposer(draftKey)
const draft = computed({
get: () => threadItems.value[draftItemIndex],
Expand Down
6 changes: 3 additions & 3 deletions components/publish/PublishWidgetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ const {
dialogLabelledBy?: string
}>()
const threadItems = computed(() =>
useThreadComposer(draftKey, initial).threadItems.value,
)
const threadComposer = useThreadComposer(draftKey, initial)
const threadItems = computed(() => threadComposer.threadItems.value)
onDeactivated(() => {
clearEmptyDrafts()
Expand All @@ -38,6 +37,7 @@ function isFirstItem(index: number) {
<PublishWidget
v-for="(_, index) in threadItems" :key="`${draftKey}-${index}`"
v-bind="$attrs"
:thread-composer="threadComposer"
:draft-key="draftKey"
:draft-item-index="index"
:expanded="isFirstItem(index) ? expanded : true"
Expand Down

0 comments on commit 4061075

Please sign in to comment.