2022-12-26 08:39:18 +03:00
|
|
|
<script setup lang="ts">
|
2022-12-27 20:47:05 +03:00
|
|
|
import type { Status } from 'masto'
|
2022-12-26 08:39:18 +03:00
|
|
|
const paginator = useMasto().timelines.iterateHome()
|
|
|
|
const stream = await useMasto().stream.streamUser()
|
|
|
|
onBeforeUnmount(() => stream.disconnect())
|
2022-12-27 20:47:05 +03:00
|
|
|
|
|
|
|
const maxDistance = 10
|
|
|
|
function preprocess(items: Status[]) {
|
|
|
|
const newItems = [...items]
|
|
|
|
// TODO: Basic reordering, we should get something more efficient and robust
|
|
|
|
for (let i = items.length - 1; i > 0; i--) {
|
|
|
|
for (let k = 1; k <= maxDistance && i - k >= 0; k++) {
|
2022-12-28 11:34:58 +03:00
|
|
|
const inReplyToId = newItems[i - k].inReplyToId // TODO: ?? newItems[i - k].reblog?.inReplyToId
|
|
|
|
if (inReplyToId === newItems[i].reblog?.id || inReplyToId === newItems[i].id) {
|
2022-12-27 20:47:05 +03:00
|
|
|
const item = newItems.splice(i, 1)[0]
|
|
|
|
newItems.splice(i - k, 0, item)
|
|
|
|
k = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newItems
|
|
|
|
}
|
2022-12-26 08:39:18 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2022-12-28 01:18:16 +03:00
|
|
|
<PublishWidget draft-key="home" border="b base" />
|
2022-12-27 20:47:05 +03:00
|
|
|
<TimelinePaginator v-bind="{ paginator, stream, preprocess }" context="home" />
|
2022-12-26 08:39:18 +03:00
|
|
|
</div>
|
|
|
|
</template>
|