1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-05 08:29:57 +00:00
elk/components/status/edit/StatusEditHistory.vue

51 lines
1.4 KiB
Vue
Raw Normal View History

2022-11-26 05:05:44 +00:00
<script setup lang="ts">
2023-01-08 06:21:09 +00:00
import type { mastodon } from 'masto'
2022-12-27 18:00:42 +00:00
import { formatTimeAgo } from '@vueuse/core'
2022-11-26 05:05:44 +00:00
const { status } = defineProps<{
2023-01-08 06:21:09 +00:00
status: mastodon.v1.Status
2022-11-26 05:05:44 +00:00
}>()
2023-01-15 08:38:02 +00:00
const paginator = useMastoClient().v1.statuses.listHistory(status.id)
2022-11-26 05:05:44 +00:00
function showHistory(edit: mastodon.v1.StatusEdit) {
2022-11-26 05:05:44 +00:00
openEditHistoryDialog(edit)
}
2022-12-02 02:18:36 +00:00
const timeAgoOptions = useTimeAgoOptions()
// TODO: rework, this is only reversing the first page of edits
function reverseHistory(items: mastodon.v1.StatusEdit[]) {
return [...items].reverse()
}
2022-11-26 05:05:44 +00:00
</script>
<template>
2023-07-02 17:34:39 +01:00
<CommonPaginator :paginator="paginator" key-prop="createdAt" :preprocess="reverseHistory">
<template #default="{ items, item, index }">
<CommonDropdownItem
px="0.5"
@click="showHistory(item)"
>
{{ getDisplayName(item.account) }}
2022-12-27 18:00:42 +00:00
<template v-if="index === items.length - 1">
<i18n-t keypath="status_history.created">
{{ formatTimeAgo(new Date(item.createdAt), timeAgoOptions) }}
</i18n-t>
</template>
<i18n-t v-else keypath="status_history.edited">
{{ formatTimeAgo(new Date(item.createdAt), timeAgoOptions) }}
2022-12-27 18:00:42 +00:00
</i18n-t>
</CommonDropdownItem>
</template>
<template #loading>
<StatusEditHistorySkeleton />
<StatusEditHistorySkeleton op50 />
<StatusEditHistorySkeleton op25 />
</template>
<template #done>
<span />
</template>
</CommonPaginator>
2022-11-26 05:05:44 +00:00
</template>