refactor(publish): extract to composables
This commit is contained in:
parent
df37e7c4de
commit
0ef99f2c8e
5 changed files with 190 additions and 122 deletions
|
@ -1,4 +1,5 @@
|
|||
import type { mastodon } from 'masto'
|
||||
import type { ComputedRef, Ref } from 'vue'
|
||||
import { STORAGE_KEY_DRAFTS } from '~/constants'
|
||||
import type { Draft, DraftMap } from '~/types'
|
||||
import type { Mutable } from '~/types/utils'
|
||||
|
@ -89,10 +90,15 @@ export const isEmptyDraft = (draft: Draft | null | undefined) => {
|
|||
&& (params.spoilerText || '').length === 0
|
||||
}
|
||||
|
||||
export interface UseDraft {
|
||||
draft: Ref<Draft>
|
||||
isEmpty: ComputedRef<boolean>
|
||||
}
|
||||
|
||||
export function useDraft(
|
||||
draftKey?: string,
|
||||
initial: () => Draft = () => getDefaultDraft({}),
|
||||
) {
|
||||
): UseDraft {
|
||||
const draft = draftKey
|
||||
? computed({
|
||||
get() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue