2022-11-16 00:21:54 +03:00
|
|
|
<script setup lang="ts">
|
2023-09-06 12:13:16 +03:00
|
|
|
import type { mastodon } from 'masto'
|
|
|
|
import { NOTIFICATION_FILTER_TYPES } from '~/constants'
|
2024-02-24 15:24:21 +03:00
|
|
|
import type { CommonRouteTabMoreOption, CommonRouteTabOption } from '~/types'
|
2023-01-24 21:52:48 +03:00
|
|
|
|
2022-11-16 00:21:54 +03:00
|
|
|
definePageMeta({
|
|
|
|
middleware: 'auth',
|
|
|
|
})
|
|
|
|
|
2023-09-06 12:13:16 +03:00
|
|
|
const route = useRoute()
|
2022-11-28 17:25:32 +03:00
|
|
|
const { t } = useI18n()
|
2023-01-29 17:18:27 +03:00
|
|
|
const pwaEnabled = useAppConfig().pwaEnabled
|
2022-11-28 17:25:32 +03:00
|
|
|
|
2024-02-21 18:20:08 +03:00
|
|
|
const tabs = computed<CommonRouteTabOption[]>(() => [
|
2022-11-30 02:25:29 +03:00
|
|
|
{
|
|
|
|
name: 'all',
|
2022-12-13 16:50:42 +03:00
|
|
|
to: '/notifications',
|
2024-02-24 15:24:21 +03:00
|
|
|
display: t('tab.notifications_all'),
|
2022-11-30 02:25:29 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'mention',
|
2022-12-13 16:50:42 +03:00
|
|
|
to: '/notifications/mention',
|
2024-02-24 15:24:21 +03:00
|
|
|
display: t('tab.notifications_mention'),
|
2022-11-30 02:25:29 +03:00
|
|
|
},
|
2023-01-24 21:52:48 +03:00
|
|
|
])
|
2023-09-06 12:13:16 +03:00
|
|
|
|
2024-02-21 18:20:08 +03:00
|
|
|
const filter = computed<mastodon.v1.NotificationType | undefined>(() => {
|
2023-09-06 12:13:16 +03:00
|
|
|
if (!isHydrated.value)
|
|
|
|
return undefined
|
|
|
|
|
|
|
|
const rawFilter = route.params?.filter
|
|
|
|
const actualFilter = Array.isArray(rawFilter) ? rawFilter[0] : rawFilter
|
|
|
|
if (isNotificationFilter(actualFilter))
|
|
|
|
return actualFilter
|
2024-03-11 13:53:25 +03:00
|
|
|
|
|
|
|
return undefined
|
2023-09-06 12:13:16 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
const filterIconMap: Record<mastodon.v1.NotificationType, string> = {
|
|
|
|
'mention': 'i-ri:at-line',
|
|
|
|
'status': 'i-ri:account-pin-circle-line',
|
|
|
|
'reblog': 'i-ri:repeat-fill',
|
|
|
|
'follow': 'i-ri:user-follow-line',
|
|
|
|
'follow_request': 'i-ri:user-shared-line',
|
|
|
|
'favourite': 'i-ri:heart-3-line',
|
|
|
|
'poll': 'i-ri:chat-poll-line',
|
|
|
|
'update': 'i-ri:edit-2-line',
|
|
|
|
'admin.sign_up': 'i-ri:user-add-line',
|
|
|
|
'admin.report': 'i-ri:flag-line',
|
|
|
|
}
|
|
|
|
|
2024-02-24 15:24:21 +03:00
|
|
|
const filterText = computed(() => `${t('tab.notifications_more_tooltip')}${filter.value ? `: ${t(`tab.notifications_${filter.value}`)}` : ''}`)
|
2024-02-21 18:20:08 +03:00
|
|
|
const notificationFilterRoutes = computed<CommonRouteTabOption[]>(() => NOTIFICATION_FILTER_TYPES.map(
|
2023-09-06 12:13:16 +03:00
|
|
|
name => ({
|
|
|
|
name,
|
|
|
|
to: `/notifications/${name}`,
|
2024-02-24 15:24:21 +03:00
|
|
|
display: t(`tab.notifications_${name}`),
|
2023-09-06 12:13:16 +03:00
|
|
|
icon: filterIconMap[name],
|
2024-02-21 18:20:08 +03:00
|
|
|
match: name === filter.value,
|
2023-09-06 12:13:16 +03:00
|
|
|
}),
|
|
|
|
))
|
2024-02-21 18:20:08 +03:00
|
|
|
const moreOptions = computed<CommonRouteTabMoreOption>(() => ({
|
|
|
|
options: notificationFilterRoutes.value,
|
2023-09-06 12:13:16 +03:00
|
|
|
icon: 'i-ri:filter-2-line',
|
2024-02-21 18:20:08 +03:00
|
|
|
tooltip: filterText.value,
|
|
|
|
match: !!filter.value,
|
2023-09-06 12:13:16 +03:00
|
|
|
}))
|
2022-11-16 00:21:54 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-12-30 21:16:23 +03:00
|
|
|
<MainContent>
|
2022-11-16 00:21:54 +03:00
|
|
|
<template #title>
|
2023-01-05 02:17:30 +03:00
|
|
|
<NuxtLink to="/notifications" timeline-title-style flex items-center gap-2 @click="$scrollToTop">
|
2022-11-29 23:15:53 +03:00
|
|
|
<div i-ri:notification-4-line />
|
2024-02-24 15:24:21 +03:00
|
|
|
<span>{{ t('nav.notifications') }}</span>
|
2022-11-29 23:15:53 +03:00
|
|
|
</NuxtLink>
|
2022-11-16 00:21:54 +03:00
|
|
|
</template>
|
2022-11-24 09:42:26 +03:00
|
|
|
|
2023-01-05 11:47:58 +03:00
|
|
|
<template #actions>
|
|
|
|
<NuxtLink
|
2022-12-18 02:29:16 +03:00
|
|
|
flex rounded-4 p1
|
|
|
|
hover:bg-active cursor-pointer transition-100
|
2024-02-24 15:24:21 +03:00
|
|
|
:title="t('settings.notifications.show_btn')"
|
2023-01-05 11:47:58 +03:00
|
|
|
to="/settings/notifications"
|
2022-12-18 02:29:16 +03:00
|
|
|
>
|
2023-01-05 11:47:58 +03:00
|
|
|
<span aria-hidden="true" i-ri:notification-badge-line />
|
|
|
|
</NuxtLink>
|
2022-12-18 02:29:16 +03:00
|
|
|
</template>
|
|
|
|
|
2022-11-23 11:08:49 +03:00
|
|
|
<template #header>
|
2023-09-06 12:13:16 +03:00
|
|
|
<CommonRouteTabs replace :options="tabs" :more-options="moreOptions" />
|
2022-11-23 11:08:49 +03:00
|
|
|
</template>
|
2022-12-18 02:29:16 +03:00
|
|
|
|
|
|
|
<slot>
|
|
|
|
<template v-if="pwaEnabled">
|
2023-01-05 11:47:58 +03:00
|
|
|
<NotificationPreferences />
|
2022-12-18 02:29:16 +03:00
|
|
|
</template>
|
2022-12-26 08:39:18 +03:00
|
|
|
|
2022-12-18 02:29:16 +03:00
|
|
|
<NuxtPage />
|
|
|
|
</slot>
|
2022-11-16 00:21:54 +03:00
|
|
|
</MainContent>
|
|
|
|
</template>
|