@quesmed/types-rn 2.2.90 → 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
|
@@ -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;
|