feat: rework status cache
This commit is contained in:
parent
9978b10e06
commit
0dc515647f
2 changed files with 39 additions and 16 deletions
18
composables/statusDrafts.ts
Normal file
18
composables/statusDrafts.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
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]
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue