elk/components/notification/NotificationCard.vue

139 lines
5 KiB
Vue
Raw Normal View History

2022-11-16 00:21:54 +03:00
<script setup lang="ts">
2023-01-08 09:21:09 +03:00
import type { mastodon } from 'masto'
2022-11-16 00:21:54 +03:00
// 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<{
notification: Notification
2022-11-16 00:21:54 +03:00
}>()
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
const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']
if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotificationTypes.includes(notification.type)) {
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
}
2022-11-16 00:21:54 +03:00
</script>
<template>
<article flex flex-col relative>
2022-11-16 00:21:54 +03:00
<template v-if="notification.type === 'follow'">
<NuxtLink :to="getAccountRoute(notification.account)">
<div
flex items-center absolute
ps-3 pe-4 inset-is-0
rounded-ie-be-3
py-3 bg-base top-0
>
<div i-ri-user-3-line text-xl me-3 color-blue />
<AccountDisplayName :account="notification.account" text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all />
<span ws-nowrap>
{{ $t('notification.followed_you') }}
</span>
</div>
<AccountBigCard
ms10
:account="notification.account"
/>
</NuxtLink>
2022-11-16 00:21:54 +03:00
</template>
2022-12-12 01:40:40 +03:00
<template v-else-if="notification.type === 'admin.sign_up'">
<NuxtLink :to="getAccountRoute(notification.account)">
<div flex p4 items-center bg-shaded>
<div i-ri:user-add-line text-xl me-2 color-purple />
<AccountDisplayName
:account="notification.account"
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
<span>{{ $t("notification.signed_up") }}</span>
</div>
</NuxtLink>
2022-12-10 00:30:16 +03:00
</template>
<template v-else-if="notification.type === 'admin.report'">
<NuxtLink :to="getReportRoute(notification.report?.id!)">
<div flex p4 items-center bg-shaded>
<div i-ri:flag-line text-xl me-2 color-purple />
<i18n-t keypath="notification.reported">
<AccountDisplayName
:account="notification.account"
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
<AccountDisplayName
:account="notification.report?.targetAccount!"
text-purple ms-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
</i18n-t>
</div>
</NuxtLink>
</template>
2022-11-26 23:48:06 +03:00
<template v-else-if="notification.type === 'follow_request'">
2023-10-22 19:11:00 +03:00
<div flex px-3 py-2>
<div i-ri-user-shared-line text-xl me-3 color-blue />
<AccountDisplayName
:account="notification.account"
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
<span me-1 ws-nowrap>
{{ $t('notification.request_to_follow') }}
</span>
2022-11-16 00:21:54 +03:00
</div>
2023-10-22 19:11:00 +03:00
<AccountCard p="s-2 e-4 b-2" hover-card :account="notification.account">
<AccountFollowRequestButton :account="notification.account" />
</AccountCard>
2022-11-16 00:21:54 +03:00
</template>
<template v-else-if="notification.type === 'update'">
2023-03-19 23:55:19 +03:00
<StatusCard :status="notification.status!" :in-notification="true" :actions="false">
2022-12-13 17:56:00 +03:00
<template #meta>
2022-12-25 22:28:26 +03:00
<div flex="~" gap-1 items-center mt1>
<div i-ri:edit-2-fill text-xl me-1 text-secondary />
<AccountInlineInfo :account="notification.account" me1 />
2022-12-13 17:56:00 +03:00
<span ws-nowrap>
{{ $t('notification.update_status') }}
</span>
2022-12-13 18:03:58 +03:00
</div>
2022-12-13 17:56:00 +03:00
</template>
</StatusCard>
</template>
<template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'">
<StatusCard :status="notification.status!" />
2022-11-16 00:21:54 +03:00
</template>
<template v-else-if="notification.type === 'annual_report'">
<div flex p4 items-center bg-shaded>
<div i-mdi:party-popper text-xl me-4 color-purple />
<div class="content-rich">
<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>
</template>
2022-11-28 02:29:21 +03:00
</article>
2022-11-16 00:21:54 +03:00
</template>