2023-12-22 17:34:50 +00:00
|
|
|
import markSeenMutation from '../mutation/notifier/mark-seen'
|
|
|
|
import markSeenAfterMutation from '../mutation/notifier/mark-seen-after'
|
|
|
|
import markThreadSeenMutation from '../mutation/notifier/mark-seen-thread'
|
2023-11-28 13:18:25 +00:00
|
|
|
import loadNotifications from '../query/notifier/notifications-load'
|
2023-12-22 17:34:50 +00:00
|
|
|
import {
|
2024-03-04 12:32:48 +00:00
|
|
|
MutationNotifications_Seen_AfterArgs,
|
2023-12-22 17:34:50 +00:00
|
|
|
NotificationsResult,
|
|
|
|
QueryLoad_NotificationsArgs,
|
2024-03-04 12:32:48 +00:00
|
|
|
} from '../schema/core.gen'
|
2024-03-04 12:51:34 +00:00
|
|
|
import { apiClient } from './core'
|
2023-11-28 13:18:25 +00:00
|
|
|
|
|
|
|
export const notifierClient = {
|
2024-03-04 12:51:34 +00:00
|
|
|
private: apiClient.private,
|
2023-11-28 13:18:25 +00:00
|
|
|
getNotifications: async (params: QueryLoad_NotificationsArgs): Promise<NotificationsResult> => {
|
2023-12-03 10:22:42 +00:00
|
|
|
const resp = await notifierClient.private.query(loadNotifications, params).toPromise()
|
2023-12-15 13:45:34 +00:00
|
|
|
return resp.data?.load_notifications
|
2023-11-28 13:18:25 +00:00
|
|
|
},
|
2023-12-22 17:34:50 +00:00
|
|
|
|
|
|
|
markSeen: async (notification_id: number): Promise<void> => {
|
2024-01-04 06:58:58 +00:00
|
|
|
// call when notification is clicked
|
2023-12-22 17:34:50 +00:00
|
|
|
await notifierClient.private.mutation(markSeenMutation, { notification_id }).toPromise()
|
2023-11-28 13:18:25 +00:00
|
|
|
},
|
|
|
|
|
2024-03-04 12:32:48 +00:00
|
|
|
markSeenAfter: async (options: MutationNotifications_Seen_AfterArgs): Promise<void> => {
|
2024-01-04 06:58:58 +00:00
|
|
|
// call when 'mark all as seen' cliecked
|
2023-12-22 17:34:50 +00:00
|
|
|
await notifierClient.private.mutation(markSeenAfterMutation, options).toPromise()
|
|
|
|
},
|
|
|
|
markSeenThread: async (thread: string): Promise<void> => {
|
2024-01-04 06:58:58 +00:00
|
|
|
// call when notification group is clicked
|
2023-12-22 17:34:50 +00:00
|
|
|
await notifierClient.private.mutation(markThreadSeenMutation, { thread }).toPromise()
|
2023-11-28 13:18:25 +00:00
|
|
|
},
|
|
|
|
}
|