diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index c4e32124..5b3b1d64 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -8,16 +8,18 @@ const { draftKey, placeholder = 'What is on your mind?', inReplyToId, + inReplyToVisibility = 'public', expanded: _expanded = false, } = defineProps<{ draftKey: string placeholder?: string inReplyToId?: string + inReplyToVisibility?: StatusVisibility expanded?: boolean }>() let isSending = $ref(false) -let { draft } = $(useDraft(draftKey, inReplyToId)) +let { draft } = $(useDraft(draftKey, inReplyToId, inReplyToVisibility)) const isExistDraft = $computed(() => !!draft.params.status && draft.params.status !== '
') let isExpanded = $ref(isExistDraft || _expanded) @@ -119,7 +121,7 @@ async function publish() { else await useMasto().statuses.update(draft.editingStatus.id, payload) - draft = getDefaultDraft({ inReplyToId }) + draft = getDefaultDraft({ inReplyToId, visibility: inReplyToVisibility }) isPublishDialogOpen.value = false } finally { diff --git a/composables/statusDrafts.ts b/composables/statusDrafts.ts index 0d1ecf54..e241a07c 100644 --- a/composables/statusDrafts.ts +++ b/composables/statusDrafts.ts @@ -1,4 +1,4 @@ -import type { Account, Attachment, CreateStatusParams, Status } from 'masto' +import type { Account, Attachment, CreateStatusParams, Status, StatusVisibility } from 'masto' import { STORAGE_KEY_DRAFTS } from '~/constants' import type { Mutable } from '~/types/utils' @@ -45,12 +45,11 @@ export function getParamsFromStatus(status: Status): Draft['params'] { } } -export function useDraft(draftKey: string, inReplyToId?: string) { +export function useDraft(draftKey: string, inReplyToId?: string, inReplyToVisibility?: StatusVisibility) { const draft = computed({ get() { if (!currentUserDrafts.value[draftKey]) - currentUserDrafts.value[draftKey] = getDefaultDraft({ inReplyToId }) - + currentUserDrafts.value[draftKey] = getDefaultDraft({ inReplyToId, visibility: inReplyToVisibility }) return currentUserDrafts.value[draftKey] }, set(val) { diff --git a/pages/@[account]/[status].vue b/pages/@[account]/[status].vue index 4e67bcc8..74f842fb 100644 --- a/pages/@[account]/[status].vue +++ b/pages/@[account]/[status].vue @@ -57,6 +57,7 @@ onReactivated(() => { :draft-key="`reply-${id}`" :placeholder="`Reply to ${status?.account ? getDisplayName(status.account) : 'this thread'}`" :in-reply-to-id="id" + :in-reply-to-visibility="status.visibility" />