@quesmed/types-rn 2.2.89 → 2.2.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.2.89",
3
+ "version": "2.2.91",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -30,3 +30,33 @@ export declare const updateNotificatonsOnMarkAsRead: (cache: ApolloCache<any>, r
30
30
  export declare type IMarkAllNotificationsAsReadVar = null;
31
31
  export declare type IMarkAllNotificationsAsReadData = RestrictedData<graphqlNormalize & INotification[], 'markAllNotificationsAsRead'>;
32
32
  export declare const MARK_ALL_AS_READ: import("@apollo/client").DocumentNode;
33
+ export declare const optimisticMarkAsRead: (notification: INotification) => () => {
34
+ restricted: {
35
+ __typename: string;
36
+ markNotificationAsRead: {
37
+ read: boolean;
38
+ id: number;
39
+ createdAt: number | Date;
40
+ updatedAt: number | Date;
41
+ deletedAt: number | Date;
42
+ userId: number | null;
43
+ user?: import("../../../models").IUser | undefined;
44
+ fromUserId: number | null;
45
+ fromUser?: import("../../../models").IUser | undefined;
46
+ commentId: number | null;
47
+ comment?: import("../../../models").IQuestionComment | undefined;
48
+ fromUserCommentId: number | null;
49
+ fromUserComment?: import("../../../models").IQuestionComment | undefined;
50
+ description: string;
51
+ actionType: ENotificationActionType;
52
+ type: ENotificationType;
53
+ global: boolean;
54
+ };
55
+ };
56
+ };
57
+ export declare const optimisticMarkAllAsRead: (notifications?: INotification[]) => () => {
58
+ restricted: {
59
+ __typename: string;
60
+ markAllNotificationsAsRead: INotification[];
61
+ };
62
+ };
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MARK_ALL_AS_READ = exports.updateNotificatonsOnMarkAsRead = exports.MARK_AS_READ = void 0;
3
+ exports.optimisticMarkAllAsRead = exports.optimisticMarkAsRead = exports.MARK_ALL_AS_READ = exports.updateNotificatonsOnMarkAsRead = exports.MARK_AS_READ = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const restricted_1 = require("../../query/restricted");
6
6
  exports.MARK_AS_READ = (0, client_1.gql) `
7
7
  mutation MarkNotificationAsread($id: Int!) {
8
8
  restricted {
9
9
  markNotificationAsRead(id: $id) {
10
- actionType
11
10
  id
12
11
  read
13
12
  }
@@ -57,10 +56,40 @@ exports.MARK_ALL_AS_READ = (0, client_1.gql) `
57
56
  mutation MarkAllNotificationsAsRead {
58
57
  restricted {
59
58
  markAllNotificationsAsRead {
60
- actionType
61
59
  id
62
60
  read
63
61
  }
64
62
  }
65
63
  }
66
64
  `;
65
+ const optimisticMarkAsRead = (notification) => () => ({
66
+ restricted: {
67
+ __typename: 'RestrictedMutation',
68
+ markNotificationAsRead: {
69
+ ...notification,
70
+ read: true,
71
+ },
72
+ },
73
+ });
74
+ exports.optimisticMarkAsRead = optimisticMarkAsRead;
75
+ const optimisticMarkAllAsRead = (notifications = []) => () => {
76
+ const index = notifications.findIndex(({ read }) => read);
77
+ const updatedNotification = notifications
78
+ .slice(0, index)
79
+ .map((notification) => ({ ...notification, read: true }));
80
+ return {
81
+ restricted: {
82
+ __typename: 'RestrictedMutation',
83
+ markAllNotificationsAsRead: [
84
+ ...updatedNotification,
85
+ ...notifications.slice(index).sort((n1, n2) => {
86
+ if (n1.read === n2.read) {
87
+ return n1.createdAt < n2.createdAt ? -1 : 1;
88
+ }
89
+ return n1.read ? 1 : -1;
90
+ }),
91
+ ],
92
+ },
93
+ };
94
+ };
95
+ exports.optimisticMarkAllAsRead = optimisticMarkAllAsRead;
@@ -11,4 +11,5 @@ export interface INewNotification {
11
11
  export declare type IOnNotificationPublisherData = RootData<INewNotification, 'onNotificationArise'>;
12
12
  export declare type IOnNotificationAriseData = RootData<INotification[], 'onNotificationArise'>;
13
13
  export declare const ON_NOTIFICATION_ARISE = "ON_NOTIFICATION_ARISE";
14
+ export declare const NOTIFICATION_ARISE: import("@apollo/client").DocumentNode;
14
15
  export declare const onNotificationArise: ({ client, subscriptionData, }: OnSubscriptionDataOptions<IOnNotificationAriseData>) => void;
@@ -1,8 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onNotificationArise = exports.ON_NOTIFICATION_ARISE = void 0;
3
+ exports.onNotificationArise = exports.NOTIFICATION_ARISE = exports.ON_NOTIFICATION_ARISE = void 0;
4
+ const client_1 = require("@apollo/client");
4
5
  const restricted_1 = require("../query/restricted");
5
6
  exports.ON_NOTIFICATION_ARISE = 'ON_NOTIFICATION_ARISE';
7
+ exports.NOTIFICATION_ARISE = (0, client_1.gql) `
8
+ subscription OnNotificationArise($userId: Int!) {
9
+ onNotificationArise(userId: $userId) {
10
+ userId
11
+ read
12
+ type
13
+ id
14
+ description
15
+ actionType
16
+ createdAt
17
+ fromUser {
18
+ id
19
+ displayName
20
+ }
21
+ comment {
22
+ id
23
+ comment
24
+ question {
25
+ id
26
+ concept {
27
+ id
28
+ name
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ `;
6
35
  const onNotificationArise = ({ client, subscriptionData, }) => {
7
36
  const { onNotificationArise } = subscriptionData.data || {};
8
37
  if (onNotificationArise) {