diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index a20f4c81..e6b6ede7 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -35,7 +35,7 @@ const { dropZoneRef, } = $(useUploadMediaAttachment($$(draft))) -let { shouldExpanded, isExpanded, isSending, isPublishDisabled, publishDraft, failedMessages, preferredLanguage } = $(usePublish( +let { shouldExpanded, isExpanded, isSending, isPublishDisabled, publishDraft, failedMessages, preferredLanguage, publishSpoilerText } = $(usePublish( { draftState, ...$$({ expanded, isUploading, initialDraft: initial }), @@ -74,6 +74,8 @@ const characterCount = $computed(() => { }).join(' ').length + 1 } + length += stringLength(publishSpoilerText) + return length }) @@ -162,7 +164,7 @@ defineExpose({
([]) + const publishSpoilerText = $computed({ + get() { + return draft.params.sensitive ? draft.params.spoilerText : '' + }, + set(val) { + if (!draft.params.sensitive) + return + draft.params.spoilerText = val + }, + }) + const shouldExpanded = $computed(() => expanded || isExpanded || !isEmpty) const isPublishDisabled = $computed(() => { return isEmpty || isUploading || isSending || (draft.attachments.length === 0 && !draft.params.status) || failedMessages.length > 0 @@ -41,6 +52,7 @@ export function usePublish(options: { const payload = { ...draft.params, + spoilerText: publishSpoilerText, status: content, mediaIds: draft.attachments.map(a => a.id), language: draft.params.language || preferredLanguage, @@ -91,6 +103,7 @@ export function usePublish(options: { isPublishDisabled, failedMessages, preferredLanguage, + publishSpoilerText, publishDraft, }) } diff --git a/composables/masto/statusDrafts.ts b/composables/masto/statusDrafts.ts index db9dc6e4..58596f32 100644 --- a/composables/masto/statusDrafts.ts +++ b/composables/masto/statusDrafts.ts @@ -89,7 +89,6 @@ export const isEmptyDraft = (draft: Draft | null | undefined) => { return (text.length === 0) && attachments.length === 0 - && (params.spoilerText || '').length === 0 } export interface UseDraft {