feat(status): mention user
This commit is contained in:
parent
0587f5f994
commit
53cf994ffd
|
@ -1,5 +1,13 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
function openDialog() {
|
||||||
|
if (dialogDraft.draft.value.editingStatus)
|
||||||
|
openPublishDialog(getDefaultDraft())
|
||||||
|
else openPublishDialog()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button btn-outline rounded-full font-bold py4 flex="~ gap2 center" @click="openPublishDialog">
|
<button btn-outline rounded-full font-bold py4 flex="~ gap2 center" @click="openDialog">
|
||||||
<div i-ri:quill-pen-line />
|
<div i-ri:quill-pen-line />
|
||||||
Compose
|
Compose
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -85,10 +85,7 @@ async function publish() {
|
||||||
await masto.statuses.create(status)
|
await masto.statuses.create(status)
|
||||||
else await masto.statuses.update(draft.editingStatus.id, status)
|
else await masto.statuses.update(draft.editingStatus.id, status)
|
||||||
|
|
||||||
draft = {
|
draft = getDefaultDraft(inReplyToId)
|
||||||
params: getDefaultStatus(inReplyToId),
|
|
||||||
attachments: [],
|
|
||||||
}
|
|
||||||
isPublishDialogOpen.value = false
|
isPublishDialogOpen.value = false
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -106,7 +103,7 @@ onUnmounted(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="currentUser" flex="~ col">
|
<div v-if="currentUser" flex="~ col gap-1">
|
||||||
<template v-if="draft.editingStatus">
|
<template v-if="draft.editingStatus">
|
||||||
<div flex="~ col gap-1">
|
<div flex="~ col gap-1">
|
||||||
<div text-gray self-center>
|
<div text-gray self-center>
|
||||||
|
@ -116,6 +113,7 @@ onUnmounted(() => {
|
||||||
</div>
|
</div>
|
||||||
<div border="b dashed gray/40" />
|
<div border="b dashed gray/40" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div p4 flex gap-4>
|
<div p4 flex gap-4>
|
||||||
<AccountAvatar :account="currentUser.account" w-12 h-12 />
|
<AccountAvatar :account="currentUser.account" w-12 h-12 />
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -84,23 +84,31 @@ const deleteAndRedraft = async () => {
|
||||||
// TODO confirm to overwrite
|
// TODO confirm to overwrite
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogDraft.draft.value = {
|
openPublishDialog({
|
||||||
params: { ...getParamsFromStatus(status), status: text! },
|
params: { ...getParamsFromStatus(status), status: text! },
|
||||||
attachments: [],
|
attachments: [],
|
||||||
}
|
})
|
||||||
openPublishDialog()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function editStatus() {
|
function editStatus() {
|
||||||
if (!dialogDraft.isEmpty) {
|
if (!dialogDraft.isEmpty) {
|
||||||
// TODO confirm to overwrite
|
// TODO confirm to overwrite
|
||||||
}
|
}
|
||||||
dialogDraft.draft.value = {
|
openPublishDialog({
|
||||||
editingStatus: status,
|
editingStatus: status,
|
||||||
params: getParamsFromStatus(status),
|
params: getParamsFromStatus(status),
|
||||||
attachments: [],
|
attachments: [],
|
||||||
}
|
})
|
||||||
openPublishDialog()
|
}
|
||||||
|
|
||||||
|
function mention() {
|
||||||
|
openPublishDialog({
|
||||||
|
params: {
|
||||||
|
...getParamsFromStatus(status),
|
||||||
|
status: `@${status.account.acct} `,
|
||||||
|
},
|
||||||
|
attachments: [],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -172,32 +180,40 @@ function editStatus() {
|
||||||
</CommonDropdownItem>
|
</CommonDropdownItem>
|
||||||
|
|
||||||
<template v-if="isAuthor">
|
<template v-if="isAuthor">
|
||||||
<!-- TODO -->
|
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-if="isAuthor" icon="i-ri:pushpin-line"
|
icon="i-ri:pushpin-line"
|
||||||
@click="togglePin"
|
@click="togglePin"
|
||||||
>
|
>
|
||||||
{{ status.pinned ? 'Unpin on profile' : 'Pin on profile' }}
|
{{ status.pinned ? 'Unpin on profile' : 'Pin on profile' }}
|
||||||
</CommonDropdownItem>
|
</CommonDropdownItem>
|
||||||
|
|
||||||
<CommonDropdownItem v-if="isAuthor" icon="i-ri:edit-line" @click="editStatus">
|
<CommonDropdownItem icon="i-ri:edit-line" @click="editStatus">
|
||||||
Edit
|
Edit
|
||||||
</CommonDropdownItem>
|
</CommonDropdownItem>
|
||||||
|
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-if="isAuthor" icon="i-ri:delete-bin-line" text-red-600
|
icon="i-ri:delete-bin-line" text-red-600
|
||||||
@click="deleteStatus"
|
@click="deleteStatus"
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</CommonDropdownItem>
|
</CommonDropdownItem>
|
||||||
|
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-if="isAuthor" icon="i-ri:eraser-line" text-red-600
|
icon="i-ri:eraser-line" text-red-600
|
||||||
@click="deleteAndRedraft"
|
@click="deleteAndRedraft"
|
||||||
>
|
>
|
||||||
Delete & re-draft
|
Delete & re-draft
|
||||||
</CommonDropdownItem>
|
</CommonDropdownItem>
|
||||||
</template>
|
</template>
|
||||||
|
<!-- TODO not available when not the same server -->
|
||||||
|
<template v-else>
|
||||||
|
<CommonDropdownItem
|
||||||
|
icon="i-ri:at-line"
|
||||||
|
@click="mention"
|
||||||
|
>
|
||||||
|
Mention @{{ status.account.acct }}
|
||||||
|
</CommonDropdownItem>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CommonDropdown>
|
</CommonDropdown>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Draft } from './statusDrafts'
|
||||||
import { STORAGE_KEY_FIRST_VISIT, STORAGE_KEY_ZEN_MODE } from '~/constants'
|
import { STORAGE_KEY_FIRST_VISIT, STORAGE_KEY_ZEN_MODE } from '~/constants'
|
||||||
|
|
||||||
export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, true)
|
export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, true)
|
||||||
|
@ -22,7 +23,9 @@ export function openPreviewHelp() {
|
||||||
isPreviewHelpOpen.value = true
|
isPreviewHelpOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openPublishDialog() {
|
export function openPublishDialog(draft?: Draft) {
|
||||||
|
if (draft)
|
||||||
|
dialogDraft.draft.value = draft
|
||||||
isPublishDialogOpen.value = true
|
isPublishDialogOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 { STORAGE_KEY_DRAFTS } from '~/constants'
|
||||||
import type { Mutable } from '~/types/utils'
|
import type { Mutable } from '~/types/utils'
|
||||||
|
|
||||||
export type DraftMap = Record<string, {
|
export interface Draft {
|
||||||
editingStatus?: Status
|
editingStatus?: Status
|
||||||
params: Omit<Mutable<CreateStatusParams>, 'status'> & { status?: Exclude<CreateStatusParams['status'], null> }
|
params: Omit<Mutable<CreateStatusParams>, 'status'> & {
|
||||||
|
status?: Exclude<CreateStatusParams['status'], null>
|
||||||
|
}
|
||||||
attachments: Attachment[]
|
attachments: Attachment[]
|
||||||
}>
|
}
|
||||||
|
export type DraftMap = Record<string, Draft>
|
||||||
|
|
||||||
const allDrafts = useLocalStorage<Record<string, DraftMap>>(STORAGE_KEY_DRAFTS, {})
|
const allDrafts = useLocalStorage<Record<string, DraftMap>>(STORAGE_KEY_DRAFTS, {})
|
||||||
|
|
||||||
|
@ -19,11 +22,14 @@ export const currentUserDrafts = computed(() => {
|
||||||
return allDrafts.value[id]
|
return allDrafts.value[id]
|
||||||
})
|
})
|
||||||
|
|
||||||
export function getDefaultStatus(inReplyToId?: string): CreateStatusParamsWithStatus {
|
export function getDefaultDraft(inReplyToId?: string): Draft {
|
||||||
return {
|
return {
|
||||||
status: '',
|
params: {
|
||||||
inReplyToId,
|
status: '',
|
||||||
visibility: 'public',
|
inReplyToId,
|
||||||
|
visibility: 'public',
|
||||||
|
},
|
||||||
|
attachments: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +44,9 @@ export function getParamsFromStatus(status: Status) {
|
||||||
export function useDraft(draftKey: string, inReplyToId?: string) {
|
export function useDraft(draftKey: string, inReplyToId?: string) {
|
||||||
const draft = computed({
|
const draft = computed({
|
||||||
get() {
|
get() {
|
||||||
if (!currentUserDrafts.value[draftKey]) {
|
if (!currentUserDrafts.value[draftKey])
|
||||||
currentUserDrafts.value[draftKey] = {
|
currentUserDrafts.value[draftKey] = getDefaultDraft(inReplyToId)
|
||||||
params: getDefaultStatus(inReplyToId),
|
|
||||||
attachments: [],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return currentUserDrafts.value[draftKey]
|
return currentUserDrafts.value[draftKey]
|
||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
|
|
Loading…
Reference in a new issue