group notifications in notification dropdown

This commit is contained in:
Moriz Wahl 2023-03-15 16:23:45 +01:00
parent 28952567b0
commit 10c02c251e
4 changed files with 24 additions and 8 deletions

View File

@ -1,16 +1,16 @@
<template>
<article :class="{ '--read': notification.read, notification: true }">
<client-only>
<user-teaser :user="from.author" :date-time="from.createdAt" />
<user-teaser :user="isGroup ? to : from.author" :date-time="from.createdAt" />
</client-only>
<p class="description">{{ $t(`notifications.reason.${notification.reason}`) }}</p>
<nuxt-link
class="link"
:to="{ name: 'post-id-slug', params, ...hashParam }"
:to="{ name: isGroup ? 'group' : 'post-id-slug', params, hashParam }"
@click.native="$emit('read')"
>
<base-card wideContent>
<h2 class="title">{{ from.title || from.post.title }}</h2>
<h2 class="title">{{ from.title || from.groupName || from.post.title }}</h2>
<p>
<strong v-if="isComment" class="comment">{{ $t(`notifications.comment`) }}:</strong>
{{ from.contentExcerpt | removeHtml }}
@ -38,14 +38,20 @@ export default {
from() {
return this.notification.from
},
to() {
return this.notification.to
},
isComment() {
return this.from.__typename === 'Comment'
},
isGroup() {
return this.from.__typename === 'Group'
},
params() {
const post = this.isComment ? this.from.post : this.from
const target = this.isComment ? this.from.post : this.from
return {
id: post.id,
slug: post.slug,
id: target.id,
slug: target.slug,
}
},
hashParam() {

View File

@ -6,6 +6,7 @@ import {
userFragment,
postFragment,
commentFragment,
groupFragment,
} from './Fragments'
export const profileUserQuery = (i18n) => {
@ -113,6 +114,7 @@ export const notificationQuery = (_i18n) => {
${userFragment}
${commentFragment}
${postFragment}
${groupFragment}
query ($read: Boolean, $orderBy: NotificationOrdering, $first: Int, $offset: Int) {
notifications(read: $read, orderBy: $orderBy, first: $first, offset: $offset) {
@ -121,6 +123,9 @@ export const notificationQuery = (_i18n) => {
reason
createdAt
updatedAt
to {
...user
}
from {
__typename
... on Post {
@ -141,6 +146,9 @@ export const notificationQuery = (_i18n) => {
}
}
}
... on Group {
...group
}
}
}
}

View File

@ -649,7 +649,8 @@
"reason": {
"commented_on_post": "Hat Deinen Beitrag kommentiert …",
"mentioned_in_comment": "Hat Dich in einem Kommentar erwähnt …",
"mentioned_in_post": "Hat Dich in einem Beitrag erwähnt …"
"mentioned_in_post": "Hat Dich in einem Beitrag erwähnt …",
"user_joined_group": "Ist Deiner Gruppe beigetreten …"
},
"title": "Benachrichtigungen",
"user": "Nutzer"

View File

@ -649,7 +649,8 @@
"reason": {
"commented_on_post": "Commented on your post …",
"mentioned_in_comment": "Mentioned you in a comment …",
"mentioned_in_post": "Mentioned you in a post …"
"mentioned_in_post": "Mentioned you in a post …",
"user_joined_group": "Joined your group …"
},
"title": "Notifications",
"user": "User"