1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-04 16:09:59 +00:00
elk/composables/statusDrafts.ts

19 lines
585 B
TypeScript
Raw Normal View History

2022-11-24 06:54:54 +00:00
import type { Attachment, CreateStatusParamsWithStatus } from 'masto'
import { STORAGE_KEY_DRAFTS } from '~/constants'
export type DraftMap = Record<string, {
params: 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]
})