Merge branch 'feature/notifier' into feature/rating
This commit is contained in:
commit
dbec93aee1
14
codegen.yml
14
codegen.yml
|
@ -25,20 +25,6 @@ generates:
|
|||
useTypeImports: true
|
||||
outputPath: './src/graphql/types/core.gen.ts'
|
||||
# namingConvention: lodash#pascalCase
|
||||
|
||||
# Generate types for notifier
|
||||
src/graphql/schema/notifier.gen.ts:
|
||||
schema: 'https://notifier.discours.io'
|
||||
plugins:
|
||||
- 'typescript'
|
||||
- 'typescript-operations'
|
||||
- 'typescript-urql'
|
||||
config:
|
||||
skipTypename: true
|
||||
useTypeImports: true
|
||||
outputPath: './src/graphql/types/notifier.gen.ts'
|
||||
# namingConvention: lodash#pascalCase
|
||||
|
||||
hooks:
|
||||
afterAllFileWrite:
|
||||
- prettier --ignore-path .gitignore --write --plugin-search-dir=. src/graphql/schema/*.gen.ts
|
||||
|
|
|
@ -4,7 +4,7 @@ import { For, Show } from 'solid-js'
|
|||
|
||||
import { useLocalize } from '../../../context/localize'
|
||||
import { useNotifications } from '../../../context/notifications'
|
||||
import { NotificationGroup as Group } from '../../../graphql/schema/notifier.gen'
|
||||
import { NotificationGroup as Group } from '../../../graphql/schema/core.gen'
|
||||
import { router, useRouter } from '../../../stores/router'
|
||||
import { ArticlePageSearchParams } from '../../Article/FullArticle'
|
||||
import { GroupAvatar } from '../../_shared/GroupAvatar'
|
||||
|
@ -39,8 +39,8 @@ const getTitle = (title: string) => {
|
|||
return shoutTitle
|
||||
}
|
||||
|
||||
const reactionsCaption = (threadId: string) =>
|
||||
threadId.includes('::') ? 'Some new replies to your comment' : 'Some new comments to your publication'
|
||||
const threadCaption = (threadId: string) =>
|
||||
threadId.includes(':') ? 'Some new replies to your comment' : 'Some new comments to your publication'
|
||||
|
||||
export const NotificationGroup = (props: NotificationGroupProps) => {
|
||||
const { t, formatTime, formatDate } = useLocalize()
|
||||
|
@ -63,12 +63,12 @@ export const NotificationGroup = (props: NotificationGroupProps) => {
|
|||
return (
|
||||
<>
|
||||
<For each={props.notifications}>
|
||||
{(n: Group) => (
|
||||
{(n: Group, index) => (
|
||||
<>
|
||||
{t(reactionsCaption(n.id), { commentsCount: n.reactions.length })}{' '}
|
||||
{t(threadCaption(n.thread), { commentsCount: n.reactions.length })}{' '}
|
||||
<div
|
||||
class={clsx(styles.NotificationView, props.class, { [styles.seen]: n.seen })}
|
||||
onClick={(_) => handleClick(n.id)}
|
||||
onClick={(_) => handleClick(n.thread)}
|
||||
>
|
||||
<div class={styles.userpic}>
|
||||
<GroupAvatar authors={n.authors} />
|
||||
|
|
|
@ -2,14 +2,13 @@ import { clsx } from 'clsx'
|
|||
import { For } from 'solid-js'
|
||||
|
||||
import { Author } from '../../../graphql/schema/core.gen'
|
||||
import { NotificationAuthor } from '../../../graphql/schema/notifier.gen'
|
||||
import { Userpic } from '../../Author/Userpic'
|
||||
|
||||
import styles from './GroupAvatar.module.scss'
|
||||
|
||||
type Props = {
|
||||
class?: string
|
||||
authors: Author[] | NotificationAuthor[]
|
||||
authors: Author[]
|
||||
}
|
||||
|
||||
export const GroupAvatar = (props: Props) => {
|
||||
|
|
|
@ -51,7 +51,7 @@ export const NotificationsProvider = (props: { children: JSX.Element }) => {
|
|||
const unread = notificationsResult?.unread || 0
|
||||
|
||||
const newGroupsEntries = groups.reduce((acc, group: NotificationGroup) => {
|
||||
acc[group.id] = group
|
||||
acc[group.thread] = group
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
|
|
|
@ -215,7 +215,6 @@ export const SessionProvider = (props: {
|
|||
if (token) {
|
||||
if (!inboxClient.private) {
|
||||
apiClient.connect(token)
|
||||
notifierClient.connect(token)
|
||||
inboxClient.connect(token)
|
||||
}
|
||||
if (!author()) loadAuthor()
|
||||
|
|
|
@ -4,15 +4,14 @@ import markSeenAfterMutation from '../mutation/notifier/mark-seen-after'
|
|||
import markThreadSeenMutation from '../mutation/notifier/mark-seen-thread'
|
||||
import loadNotifications from '../query/notifier/notifications-load'
|
||||
import {
|
||||
MutationMark_Seen_AfterArgs,
|
||||
MutationNotifications_Seen_AfterArgs,
|
||||
NotificationsResult,
|
||||
QueryLoad_NotificationsArgs,
|
||||
} from '../schema/notifier.gen'
|
||||
} from '../schema/core.gen'
|
||||
import { apiClient } from './core'
|
||||
|
||||
export const notifierClient = {
|
||||
private: null,
|
||||
connect: (token: string) => (notifierClient.private = createGraphQLClient('notifier', token)),
|
||||
|
||||
private: apiClient.private,
|
||||
getNotifications: async (params: QueryLoad_NotificationsArgs): Promise<NotificationsResult> => {
|
||||
const resp = await notifierClient.private.query(loadNotifications, params).toPromise()
|
||||
return resp.data?.load_notifications
|
||||
|
@ -23,7 +22,7 @@ export const notifierClient = {
|
|||
await notifierClient.private.mutation(markSeenMutation, { notification_id }).toPromise()
|
||||
},
|
||||
|
||||
markSeenAfter: async (options: MutationMark_Seen_AfterArgs): Promise<void> => {
|
||||
markSeenAfter: async (options: MutationNotifications_Seen_AfterArgs): Promise<void> => {
|
||||
// call when 'mark all as seen' cliecked
|
||||
await notifierClient.private.mutation(markSeenAfterMutation, options).toPromise()
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user