forked from Mirrors/elk
feat: add notification tabs pages (#410)
This commit is contained in:
parent
d546390f5c
commit
fd29c379dc
3 changed files with 42 additions and 23 deletions
|
@ -5,35 +5,18 @@ definePageMeta({
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
// 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'] })
|
|
||||||
|
|
||||||
const { clearNotifications } = useNotifications()
|
|
||||||
onActivated(clearNotifications)
|
|
||||||
|
|
||||||
const stream = await useMasto().stream.streamUser()
|
|
||||||
|
|
||||||
const tabs = $computed(() => [
|
const tabs = $computed(() => [
|
||||||
{
|
{
|
||||||
name: 'all',
|
name: 'all',
|
||||||
|
to: '/notifications',
|
||||||
display: t('tab.notifications_all'),
|
display: t('tab.notifications_all'),
|
||||||
paginator: paginatorAll,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mention',
|
name: 'mention',
|
||||||
|
to: '/notifications/mention',
|
||||||
display: t('tab.notifications_mention'),
|
display: t('tab.notifications_mention'),
|
||||||
paginator: paginatorMention,
|
|
||||||
},
|
},
|
||||||
] as const)
|
] 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)
|
|
||||||
|
|
||||||
useHeadFixed({
|
|
||||||
title: () => t('nav_side.notifications'),
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -46,10 +29,8 @@ useHeadFixed({
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<CommonTabs v-model="tab" :options="tabs" />
|
<CommonRouteTabs replace :options="tabs" />
|
||||||
</template>
|
</template>
|
||||||
<slot>
|
<NuxtPage />
|
||||||
<NotificationPaginator :key="tab" v-bind="{ paginator, stream }" />
|
|
||||||
</slot>
|
|
||||||
</MainContent>
|
</MainContent>
|
||||||
</template>
|
</template>
|
||||||
|
|
19
pages/notifications/index.vue
Normal file
19
pages/notifications/index.vue
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// Default limit is 20 notifications, and servers are normally caped to 30
|
||||||
|
const paginator = useMasto().notifications.iterate({ limit: 30 })
|
||||||
|
|
||||||
|
const { clearNotifications } = useNotifications()
|
||||||
|
onActivated(clearNotifications)
|
||||||
|
|
||||||
|
const stream = await useMasto().stream.streamUser()
|
||||||
|
|
||||||
|
useHeadFixed({
|
||||||
|
title: () => `${t('tab.notifications_all')} | ${t('nav_side.notifications')}`,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NotificationPaginator v-bind="{ paginator, stream }" />
|
||||||
|
</template>
|
19
pages/notifications/mention.vue
Normal file
19
pages/notifications/mention.vue
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// Default limit is 20 notifications, and servers are normally caped to 30
|
||||||
|
const paginator = useMasto().notifications.iterate({ limit: 30, types: ['mention'] })
|
||||||
|
|
||||||
|
const { clearNotifications } = useNotifications()
|
||||||
|
onActivated(clearNotifications)
|
||||||
|
|
||||||
|
const stream = await useMasto().stream.streamUser()
|
||||||
|
|
||||||
|
useHeadFixed({
|
||||||
|
title: () => `${t('tab.notifications_mention')} | ${t('nav_side.notifications')}`,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NotificationPaginator v-bind="{ paginator, stream }" />
|
||||||
|
</template>
|
Loading…
Reference in a new issue