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

View File

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

View File

@ -649,7 +649,8 @@
"reason": { "reason": {
"commented_on_post": "Hat Deinen Beitrag kommentiert …", "commented_on_post": "Hat Deinen Beitrag kommentiert …",
"mentioned_in_comment": "Hat Dich in einem Kommentar erwähnt …", "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", "title": "Benachrichtigungen",
"user": "Nutzer" "user": "Nutzer"

View File

@ -649,7 +649,8 @@
"reason": { "reason": {
"commented_on_post": "Commented on your post …", "commented_on_post": "Commented on your post …",
"mentioned_in_comment": "Mentioned you in a comment …", "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", "title": "Notifications",
"user": "User" "user": "User"