From 4061075ddeccbd3ebab9085e0f5a4e201ef845cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Wed, 11 Sep 2024 22:37:14 +0200 Subject: [PATCH] fix(ui): generate only one thread composer in `PublishWidgetList` and provide it to each widget (#2953) --- components/publish/PublishWidget.vue | 4 +++- components/publish/PublishWidgetList.vue | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index 16d20b8a..c9bc246d 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -5,6 +5,7 @@ import type { mastodon } from 'masto' import type { DraftItem } from '~/types' const { + threadComposer, draftKey, draftItemIndex, expanded = false, @@ -15,6 +16,7 @@ const { draftKey: string draftItemIndex: number initial?: () => DraftItem + threadComposer?: ReturnType placeholder?: string inReplyToId?: string inReplyToVisibility?: mastodon.v1.StatusVisibility @@ -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], diff --git a/components/publish/PublishWidgetList.vue b/components/publish/PublishWidgetList.vue index 31b7b9c4..9e625d2a 100644 --- a/components/publish/PublishWidgetList.vue +++ b/components/publish/PublishWidgetList.vue @@ -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() @@ -38,6 +37,7 @@ function isFirstItem(index: number) {