{
// TODO confirm to overwrite
}
- dialogDraft.draft.value = {
+ openPublishDialog({
params: { ...getParamsFromStatus(status), status: text! },
attachments: [],
- }
- openPublishDialog()
+ })
}
function editStatus() {
if (!dialogDraft.isEmpty) {
// TODO confirm to overwrite
}
- dialogDraft.draft.value = {
+ openPublishDialog({
editingStatus: status,
params: getParamsFromStatus(status),
attachments: [],
- }
- openPublishDialog()
+ })
+}
+
+function mention() {
+ openPublishDialog({
+ params: {
+ ...getParamsFromStatus(status),
+ status: `@${status.account.acct} `,
+ },
+ attachments: [],
+ })
}
@@ -172,32 +180,40 @@ function editStatus() {
-
{{ status.pinned ? 'Unpin on profile' : 'Pin on profile' }}
-
+
Edit
Delete
Delete & re-draft
+
+
+
+ Mention @{{ status.account.acct }}
+
+
diff --git a/composables/dialog.ts b/composables/dialog.ts
index fd375fe9..429af5db 100644
--- a/composables/dialog.ts
+++ b/composables/dialog.ts
@@ -1,3 +1,4 @@
+import type { Draft } from './statusDrafts'
import { STORAGE_KEY_FIRST_VISIT, STORAGE_KEY_ZEN_MODE } from '~/constants'
export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, true)
@@ -22,7 +23,9 @@ export function openPreviewHelp() {
isPreviewHelpOpen.value = true
}
-export function openPublishDialog() {
+export function openPublishDialog(draft?: Draft) {
+ if (draft)
+ dialogDraft.draft.value = draft
isPublishDialogOpen.value = true
}
diff --git a/composables/statusDrafts.ts b/composables/statusDrafts.ts
index efe9f7c3..c804a923 100644
--- a/composables/statusDrafts.ts
+++ b/composables/statusDrafts.ts
@@ -1,12 +1,15 @@
-import type { Attachment, CreateStatusParams, CreateStatusParamsWithStatus, Status } from 'masto'
+import type { Attachment, CreateStatusParams, Status } from 'masto'
import { STORAGE_KEY_DRAFTS } from '~/constants'
import type { Mutable } from '~/types/utils'
-export type DraftMap = Record
, 'status'> & { status?: Exclude }
+ params: Omit, 'status'> & {
+ status?: Exclude
+ }
attachments: Attachment[]
-}>
+}
+export type DraftMap = Record
const allDrafts = useLocalStorage>(STORAGE_KEY_DRAFTS, {})
@@ -19,11 +22,14 @@ export const currentUserDrafts = computed(() => {
return allDrafts.value[id]
})
-export function getDefaultStatus(inReplyToId?: string): CreateStatusParamsWithStatus {
+export function getDefaultDraft(inReplyToId?: string): Draft {
return {
- status: '',
- inReplyToId,
- visibility: 'public',
+ params: {
+ status: '',
+ inReplyToId,
+ visibility: 'public',
+ },
+ attachments: [],
}
}
@@ -38,12 +44,9 @@ export function getParamsFromStatus(status: Status) {
export function useDraft(draftKey: string, inReplyToId?: string) {
const draft = computed({
get() {
- if (!currentUserDrafts.value[draftKey]) {
- currentUserDrafts.value[draftKey] = {
- params: getDefaultStatus(inReplyToId),
- attachments: [],
- }
- }
+ if (!currentUserDrafts.value[draftKey])
+ currentUserDrafts.value[draftKey] = getDefaultDraft(inReplyToId)
+
return currentUserDrafts.value[draftKey]
},
set(val) {