mattwr18 7cdc12f4b9 Add notifications page with Notifications in table
- At the moment, the notifications are displayed in a table, and have
the same functionality as the NotificationMenu where you can click on
the title of the Post and visit the Post

- Unsure about the styling, it would kind of be nice to have a more
condensed list to see more notifications per page, but still be able to
click on a row and visit the Post
2019-11-11 08:50:35 +01:00

167 lines
2.9 KiB
JavaScript

import gql from 'graphql-tag'
import { userFragment, postFragment, commentFragment } from './Fragments'
export default i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment(lang)}
query User($id: ID!) {
User(id: $id) {
...user
about
locationName
createdAt
badgesCount
followingCount
following(first: 7) {
...user
}
followedByCount
followedByCurrentUser
isBlocked
followedBy(first: 7) {
...user
}
socialMedia {
id
url
}
}
}
`
}
export const minimisedUserQuery = () => {
return gql`
query {
User(orderBy: slug_asc) {
id
slug
name
avatar
}
}
`
}
export const notificationQuery = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${commentFragment(lang)}
${postFragment(lang)}
query {
notifications(orderBy: updatedAt_desc) {
read
reason
createdAt
from {
__typename
... on Post {
...post
}
... on Comment {
...comment
post {
...post
}
}
}
}
}
`
}
export const markAsReadMutation = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${commentFragment(lang)}
${postFragment(lang)}
mutation($id: ID!) {
markAsRead(id: $id) {
read
reason
createdAt
from {
__typename
... on Post {
...post
}
... on Comment {
...comment
post {
...post
}
}
}
}
}
`
}
export const followUserMutation = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment(lang)}
mutation($id: ID!) {
followUser(id: $id) {
name
followedByCount
followedByCurrentUser
followedBy(first: 7) {
...user
}
}
}
`
}
export const unfollowUserMutation = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment(lang)}
mutation($id: ID!) {
unfollowUser(id: $id) {
name
followedByCount
followedByCurrentUser
followedBy(first: 7) {
...user
}
}
}
`
}
export const allowEmbedIframesMutation = () => {
return gql`
mutation($id: ID!, $allowEmbedIframes: Boolean) {
UpdateUser(id: $id, allowEmbedIframes: $allowEmbedIframes) {
id
allowEmbedIframes
}
}
`
}
export const checkSlugAvailableQuery = gql`
query($slug: String!) {
User(slug: $slug) {
slug
}
}
`
export const localeMutation = () => {
return gql`
mutation($id: ID!, $locale: String) {
UpdateUser(id: $id, locale: $locale) {
id
locale
}
}
`
}