feat: support 'annual_report' notification type (#3084)
This commit is contained in:
parent
62e6bdf43c
commit
fb411e89f4
1 changed files with 39 additions and 7 deletions
|
@ -1,16 +1,38 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
|
// Add undocumented 'annual_report' type introduced in v4.3
|
||||||
|
// ref. https://github.com/mastodon/documentation/issues/1211#:~:text=api/v1/annual_reports
|
||||||
|
type NotificationType = mastodon.v1.Notification['type'] | 'annual_report'
|
||||||
|
type Notification = Omit<mastodon.v1.Notification, 'type'> & { type: NotificationType }
|
||||||
|
|
||||||
const { notification } = defineProps<{
|
const { notification } = defineProps<{
|
||||||
notification: mastodon.v1.Notification
|
notification: Notification
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// list of notification types Elk currently implemented
|
||||||
|
// type 'favourite' and 'reblog' should always rendered by NotificationGroupedLikes
|
||||||
|
const supportedNotificationTypes: NotificationType[] = [
|
||||||
|
'follow',
|
||||||
|
'admin.sign_up',
|
||||||
|
'admin.report',
|
||||||
|
'follow_request',
|
||||||
|
'update',
|
||||||
|
'mention',
|
||||||
|
'poll',
|
||||||
|
'update',
|
||||||
|
'status',
|
||||||
|
'annual_report',
|
||||||
|
]
|
||||||
|
|
||||||
// well-known emoji reactions types Elk does not support yet
|
// well-known emoji reactions types Elk does not support yet
|
||||||
const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']
|
const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']
|
||||||
if (unsupportedEmojiReactionTypes.includes(notification.type))
|
|
||||||
|
if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotificationTypes.includes(notification.type)) {
|
||||||
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
|
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -95,11 +117,21 @@ if (unsupportedEmojiReactionTypes.includes(notification.type))
|
||||||
<template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'">
|
<template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'">
|
||||||
<StatusCard :status="notification.status!" />
|
<StatusCard :status="notification.status!" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="!unsupportedEmojiReactionTypes.includes(notification.type)">
|
<template v-else-if="notification.type === 'annual_report'">
|
||||||
<!-- prevent showing errors for dev for known emoji reaction types -->
|
<div flex p4 items-center bg-shaded>
|
||||||
<!-- type 'favourite' and 'reblog' should always rendered by NotificationGroupedLikes -->
|
<div i-mdi:party-popper text-xl me-4 color-purple />
|
||||||
<div text-red font-bold>
|
<div class="content-rich">
|
||||||
[DEV] {{ $t('notification.missing_type') }} '{{ notification.type }}'
|
<p>
|
||||||
|
Your 2024 <NuxtLink to="/tags/Wrapstodon">
|
||||||
|
#Wrapstodon
|
||||||
|
</NuxtLink> awaits! Unveil your year's highlights and memorable moments on Mastodon!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<NuxtLink :to="`https://${currentServer}/notifications`" target="_blank">
|
||||||
|
View #Wrapstodon on Mastodon
|
||||||
|
</NuxtLink>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</article>
|
</article>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue