1
0
mirror of https://github.com/elk-zone/elk synced 2024-12-23 11:08:04 +09:00
elk/pages/notifications.vue

56 lines
1.5 KiB
Vue
Raw Normal View History

2022-11-16 06:21:54 +09:00
<script setup lang="ts">
definePageMeta({
middleware: 'auth',
})
2022-11-28 23:25:32 +09:00
const { t } = useI18n()
2022-12-12 07:40:40 +09:00
// Default limit is 20 notifications, and servers are normally caped to 30
const paginatorAll = useMasto().notifications.iterate({ limit: 30 })
const paginatorMention = useMasto().notifications.iterate({ limit: 30, types: ['mention'] })
2022-11-20 00:15:19 +09:00
const { clearNotifications } = useNotifications()
onActivated(clearNotifications)
const stream = await useMasto().stream.streamUser()
2022-11-30 08:25:29 +09:00
const tabs = $computed(() => [
{
name: 'all',
display: t('tab.notifications_all'),
paginator: paginatorAll,
},
{
name: 'mention',
display: t('tab.notifications_mention'),
paginator: paginatorMention,
},
] as const)
// Don't use local storage because it is better to default to Posts every time you visit a user's profile.
const tab = $ref(tabs[0].name)
const paginator = $computed(() => tabs.find(t => t.name === tab)!.paginator)
2022-11-25 20:48:48 +09:00
useHeadFixed({
2022-11-28 23:25:32 +09:00
title: () => t('nav_side.notifications'),
2022-11-25 20:48:48 +09:00
})
2022-11-16 06:21:54 +09:00
</script>
<template>
<MainContent>
<template #title>
2022-11-30 05:15:53 +09:00
<NuxtLink to="/notifications" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:notification-4-line />
<span>{{ t('nav_side.notifications') }}</span>
</NuxtLink>
2022-11-16 06:21:54 +09:00
</template>
2022-11-24 15:42:26 +09:00
2022-11-23 17:08:49 +09:00
<template #header>
2022-11-30 08:25:29 +09:00
<CommonTabs v-model="tab" :options="tabs" />
2022-11-23 17:08:49 +09:00
</template>
<slot>
<NotificationPaginator :key="tab" v-bind="{ paginator, stream }" />
2022-11-16 06:21:54 +09:00
</slot>
</MainContent>
</template>