2022-12-26 06:39:18 +01:00
|
|
|
<script setup lang="ts">
|
2023-01-23 20:33:21 +01:00
|
|
|
import type { mastodon } from 'masto'
|
|
|
|
|
2023-01-15 09:38:02 +01:00
|
|
|
const paginator = useMastoClient().v1.timelines.listHome({ limit: 30 })
|
|
|
|
const stream = $(useStreaming(client => client.v1.stream.streamUser()))
|
2023-04-02 16:56:13 +02:00
|
|
|
|
2023-03-30 21:01:24 +02:00
|
|
|
function reorderAndFilter(items: mastodon.v1.Status[]) {
|
|
|
|
return reorderedTimeline(items, 'home')
|
|
|
|
}
|
2023-04-02 16:56:13 +02:00
|
|
|
|
|
|
|
const homeFilter = useHomeFilter()
|
|
|
|
|
|
|
|
function clientSideFilter(items: mastodon.v1.Status[]) {
|
|
|
|
const { bot, sensitive, repost, mutual, tag } = $(homeFilter.value)
|
|
|
|
|
|
|
|
return items.filter((item) => {
|
|
|
|
if (bot && sensitive && repost && mutual && tag)
|
|
|
|
return true
|
|
|
|
|
|
|
|
if (!bot && item.account.bot)
|
|
|
|
return false
|
|
|
|
|
|
|
|
if (!sensitive && item.sensitive)
|
|
|
|
return false
|
|
|
|
|
|
|
|
if (!repost && item.reblog != null)
|
|
|
|
return false
|
|
|
|
|
|
|
|
// if (!mutual && ??)
|
|
|
|
// This would require a lookup of the user's followers
|
|
|
|
// return false
|
|
|
|
|
|
|
|
// if (!tag && ??)
|
|
|
|
// This would require a lookup of the user's tags
|
|
|
|
// return false
|
|
|
|
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const nuxtApp = useNuxtApp()
|
|
|
|
|
|
|
|
watch(homeFilter, () => {
|
|
|
|
nuxtApp.hooks.callHook('elk-timeline-home-filter:change')
|
|
|
|
})
|
2022-12-26 06:39:18 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2022-12-27 23:18:16 +01:00
|
|
|
<PublishWidget draft-key="home" border="b base" />
|
2023-04-02 16:56:13 +02:00
|
|
|
<TimelinePaginator v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" :postprocess="clientSideFilter" context="home" />
|
2022-12-26 06:39:18 +01:00
|
|
|
</div>
|
|
|
|
</template>
|