mirror of
https://github.com/elk-zone/elk.git
synced 2024-09-06 20:29:08 +01:00
20 lines
639 B
TypeScript
20 lines
639 B
TypeScript
import type { Attachment, CreateStatusParamsWithStatus } from 'masto'
|
|
import { STORAGE_KEY_DRAFTS } from '~/constants'
|
|
import type { Mutable } from '~/types/utils'
|
|
|
|
export type DraftMap = Record<string, {
|
|
params: Mutable<CreateStatusParamsWithStatus>
|
|
attachments: Attachment[]
|
|
}>
|
|
|
|
const allDrafts = useLocalStorage<Record<string, DraftMap>>(STORAGE_KEY_DRAFTS, {})
|
|
|
|
export const currentUserDrafts = computed(() => {
|
|
if (!currentUser.value?.account?.id)
|
|
return {}
|
|
const id = `${currentUser.value.account.acct}@${currentUser.value.server}`
|
|
if (!allDrafts.value[id])
|
|
allDrafts.value[id] = {}
|
|
return allDrafts.value[id]
|
|
})
|