2023-01-05 15:42:36 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { formatTimeAgo } from '@vueuse/core'
|
|
|
|
|
|
|
|
const route = useRoute()
|
2023-01-08 12:54:05 +00:00
|
|
|
const { formatNumber } = useHumanReadableNumber()
|
|
|
|
const timeAgoOptions = useTimeAgoOptions()
|
2023-01-05 15:42:36 +00:00
|
|
|
|
|
|
|
let draftKey = $ref('home')
|
|
|
|
|
|
|
|
const draftKeys = $computed(() => Object.keys(currentUserDrafts.value))
|
|
|
|
const nonEmptyDrafts = $computed(() => draftKeys
|
|
|
|
.filter(i => i !== draftKey && !isEmptyDraft(currentUserDrafts.value[i]))
|
|
|
|
.map(i => [i, currentUserDrafts.value[i]] as const),
|
|
|
|
)
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
draftKey = route.query.draft?.toString() || 'home'
|
|
|
|
})
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
clearEmptyDrafts()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex="~ col" pt-6 h-screen>
|
|
|
|
<div text-right h-8>
|
|
|
|
<VDropdown v-if="nonEmptyDrafts.length" placement="bottom-end">
|
|
|
|
<button btn-text flex="inline center">
|
2023-01-08 12:54:05 +00:00
|
|
|
{{ $t('compose.drafts', nonEmptyDrafts.length, { named: { v: formatNumber(nonEmptyDrafts.length) } }) }} <div aria-hidden="true" i-ri:arrow-down-s-line />
|
2023-01-05 15:42:36 +00:00
|
|
|
</button>
|
|
|
|
<template #popper="{ hide }">
|
|
|
|
<div flex="~ col">
|
|
|
|
<NuxtLink
|
|
|
|
v-for="[key, draft] of nonEmptyDrafts" :key="key"
|
|
|
|
border="b base" text-left py2 px4 hover:bg-active
|
|
|
|
:replace="true"
|
|
|
|
:to="`/compose?draft=${encodeURIComponent(key)}`"
|
|
|
|
@click="hide()"
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<div flex="~ gap-1" items-center>
|
2023-01-08 12:54:05 +00:00
|
|
|
<i18n-t keypath="compose.draft_title">
|
|
|
|
<code>{{ key }}</code>
|
|
|
|
</i18n-t>
|
2023-01-05 15:42:36 +00:00
|
|
|
<span v-if="draft.lastUpdated" text-secondary text-sm>
|
2023-01-08 12:54:05 +00:00
|
|
|
· {{ formatTimeAgo(new Date(draft.lastUpdated), timeAgoOptions) }}
|
2023-01-05 15:42:36 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div text-secondary>
|
|
|
|
{{ htmlToText(draft.params.status).slice(0, 50) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</NuxtLink>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</VDropdown>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<PublishWidget :key="draftKey" expanded class="min-h-100!" :draft-key="draftKey" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|