@quesmed/types-rn 2.2.90 → 2.2.92
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;
|
|
@@ -9,15 +9,21 @@ interface LikeData {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const getLikeData: (like: EQuestionLike, item: LikeData) => LikeData;
|
|
11
11
|
export declare const getQuestionTypeName: (typeId: EQuestionType) => string;
|
|
12
|
+
export declare const updatedCommentsOnAdd: (newComment: IQuestionComment, comments: IQuestionComment[], parentId?: number | undefined) => IQuestionComment[];
|
|
13
|
+
export declare const updateCommentsOnRemove: (comments: IQuestionComment[], commentId: number, parentId?: number | undefined) => IQuestionComment[];
|
|
14
|
+
export declare const updatedCommentsInMarksheetQuestion: (cache: ApolloCache<any>, questionComments: IQuestionComment, marksheetId: number, questionId: number, parentId?: number | undefined) => void;
|
|
15
|
+
export declare const updatedCommentsInQuestion: (cache: ApolloCache<any>, questionComments: IQuestionComment, questionId: number, parentId?: number | undefined) => void;
|
|
16
|
+
export declare const updatedRemoveCommentsInMarksheetQuestion: (cache: ApolloCache<any>, marksheetId: number, questionId: number, commentId: number, parentId?: number | undefined) => void;
|
|
17
|
+
export declare const updatedRemoveCommentsInQuestion: (cache: ApolloCache<any>, questionId: number, commentId: number, parentId?: number | undefined) => void;
|
|
12
18
|
export declare const QUESTION_LIKE: import("@apollo/client").DocumentNode;
|
|
13
|
-
export declare const optimisticQuestionLike: (
|
|
19
|
+
export declare const optimisticQuestionLike: (client: ApolloClient<any>, input: IQuestionLikeVar, marksheetId?: number | undefined) => IQuestionLikeData;
|
|
14
20
|
export interface IQuestionLikeVar {
|
|
15
21
|
questionId: Id;
|
|
16
22
|
like: EQuestionLike;
|
|
17
23
|
}
|
|
18
24
|
export declare type IQuestionLikeData = RestrictedData<graphqlNormalize & IQuestion, 'questionLike'>;
|
|
19
25
|
export declare const QUESTION_COMMENTS: import("@apollo/client").DocumentNode;
|
|
20
|
-
export declare const updateQuestionComments: (marksheetId
|
|
26
|
+
export declare const updateQuestionComments: (marksheetId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IQuestionCommentsData>, options: ApolloUpdateOptions) => void;
|
|
21
27
|
export declare const optimisticQuestionComment: (id: number, user: {
|
|
22
28
|
id: number;
|
|
23
29
|
displayName: string;
|
|
@@ -36,7 +42,7 @@ export interface IQuestionCommentsLikeVar {
|
|
|
36
42
|
}
|
|
37
43
|
export declare type IQuestionCommentsLikeData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionCommentLike'>;
|
|
38
44
|
export declare const QUESTION_COMMENT_REMOVE: import("@apollo/client").DocumentNode;
|
|
39
|
-
export declare const updateQuestionCommentsRemove: (marksheetId
|
|
45
|
+
export declare const updateQuestionCommentsRemove: (marksheetId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IQuestionCommentRemoveData>, options: ApolloUpdateOptions) => void;
|
|
40
46
|
export declare const optimisticQuestionCommentRemove: (comments: IQuestionComment[], input: IQuestionCommentRemoveVar, parentId?: number | undefined) => IQuestionCommentRemoveData;
|
|
41
47
|
export interface IQuestionCommentRemoveVar {
|
|
42
48
|
commentId: Id;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.optimisticQuestionCommentRemove = exports.updateQuestionCommentsRemove = exports.QUESTION_COMMENT_REMOVE = exports.optimisticCommentLike = exports.QUESTION_COMMENT_LIKE = exports.optimisticQuestionComment = exports.updateQuestionComments = exports.QUESTION_COMMENTS = exports.optimisticQuestionLike = exports.QUESTION_LIKE = exports.getQuestionTypeName = exports.getLikeData = void 0;
|
|
3
|
+
exports.optimisticQuestionCommentRemove = exports.updateQuestionCommentsRemove = exports.QUESTION_COMMENT_REMOVE = exports.optimisticCommentLike = exports.QUESTION_COMMENT_LIKE = exports.optimisticQuestionComment = exports.updateQuestionComments = exports.QUESTION_COMMENTS = exports.optimisticQuestionLike = exports.QUESTION_LIKE = exports.updatedRemoveCommentsInQuestion = exports.updatedRemoveCommentsInMarksheetQuestion = exports.updatedCommentsInQuestion = exports.updatedCommentsInMarksheetQuestion = exports.updateCommentsOnRemove = exports.updatedCommentsOnAdd = exports.getQuestionTypeName = exports.getLikeData = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
const models_1 = require("../../../models");
|
|
6
6
|
const restricted_1 = require("../../query/restricted");
|
|
@@ -43,6 +43,161 @@ const getQuestionTypeName = (typeId) => {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
exports.getQuestionTypeName = getQuestionTypeName;
|
|
46
|
+
const updatedCommentsOnAdd = (newComment, comments, parentId) => {
|
|
47
|
+
if (parentId) {
|
|
48
|
+
const commentIndex = comments.findIndex(({ id }) => Number(id) === parentId);
|
|
49
|
+
const { replies = [], ...commentRest } = comments[commentIndex];
|
|
50
|
+
return [
|
|
51
|
+
...comments.slice(0, commentIndex),
|
|
52
|
+
{ ...commentRest, replies: [...replies, newComment] },
|
|
53
|
+
...comments.slice(commentIndex + 1),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
return [...comments, newComment];
|
|
57
|
+
};
|
|
58
|
+
exports.updatedCommentsOnAdd = updatedCommentsOnAdd;
|
|
59
|
+
const updateCommentsOnRemove = (comments, commentId, parentId) => {
|
|
60
|
+
if (parentId) {
|
|
61
|
+
const commentIndex = comments.findIndex(({ id }) => Number(id) === Number(parentId));
|
|
62
|
+
const { replies = [], ...commentRest } = comments[commentIndex];
|
|
63
|
+
return [
|
|
64
|
+
...comments.slice(0, commentIndex),
|
|
65
|
+
{
|
|
66
|
+
...commentRest,
|
|
67
|
+
replies: replies.filter(({ id }) => Number(id) !== Number(commentId)),
|
|
68
|
+
},
|
|
69
|
+
...comments.slice(commentIndex + 1),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
return comments.filter(({ id }) => Number(id) !== Number(commentId));
|
|
73
|
+
};
|
|
74
|
+
exports.updateCommentsOnRemove = updateCommentsOnRemove;
|
|
75
|
+
const updatedCommentsInMarksheetQuestion = (cache, questionComments, marksheetId, questionId, parentId) => {
|
|
76
|
+
const marksheetData = cache.readQuery({
|
|
77
|
+
variables: { id: marksheetId },
|
|
78
|
+
query: restricted_1.MARKSHEET,
|
|
79
|
+
});
|
|
80
|
+
if (marksheetData) {
|
|
81
|
+
const { marksheet } = marksheetData.restricted || {};
|
|
82
|
+
const { marks, ...marksheetRest } = marksheet;
|
|
83
|
+
const index = marks.findIndex(({ question }) => Number(question.id) === Number(questionId));
|
|
84
|
+
const { question, ...markRest } = marks[index];
|
|
85
|
+
const { comments = [], ...questionRest } = question;
|
|
86
|
+
cache.writeQuery({
|
|
87
|
+
query: restricted_1.MARKSHEET,
|
|
88
|
+
variables: { id: marksheetId },
|
|
89
|
+
data: {
|
|
90
|
+
...marksheetData,
|
|
91
|
+
restricted: {
|
|
92
|
+
...marksheetData.restricted,
|
|
93
|
+
marksheet: {
|
|
94
|
+
...marksheetRest,
|
|
95
|
+
marks: [
|
|
96
|
+
...marks.slice(0, index),
|
|
97
|
+
{
|
|
98
|
+
...markRest,
|
|
99
|
+
question: {
|
|
100
|
+
...questionRest,
|
|
101
|
+
comments: (0, exports.updatedCommentsOnAdd)(questionComments, comments, parentId),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
...marks.slice(index + 1),
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.updatedCommentsInMarksheetQuestion = updatedCommentsInMarksheetQuestion;
|
|
113
|
+
const updatedCommentsInQuestion = (cache, questionComments, questionId, parentId) => {
|
|
114
|
+
const questionData = cache.readQuery({
|
|
115
|
+
variables: { id: questionId },
|
|
116
|
+
query: restricted_1.QUESTION,
|
|
117
|
+
});
|
|
118
|
+
if (questionData) {
|
|
119
|
+
const { question } = questionData.restricted || {};
|
|
120
|
+
const { comments = [], ...questionRest } = question;
|
|
121
|
+
cache.writeQuery({
|
|
122
|
+
query: restricted_1.QUESTION,
|
|
123
|
+
variables: { id: questionId },
|
|
124
|
+
data: {
|
|
125
|
+
...questionData,
|
|
126
|
+
restricted: {
|
|
127
|
+
...questionData.restricted,
|
|
128
|
+
question: {
|
|
129
|
+
...questionRest,
|
|
130
|
+
comments: (0, exports.updatedCommentsOnAdd)(questionComments, comments, parentId),
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
exports.updatedCommentsInQuestion = updatedCommentsInQuestion;
|
|
138
|
+
const updatedRemoveCommentsInMarksheetQuestion = (cache, marksheetId, questionId, commentId, parentId) => {
|
|
139
|
+
const marksheetData = cache.readQuery({
|
|
140
|
+
variables: { id: marksheetId },
|
|
141
|
+
query: restricted_1.MARKSHEET,
|
|
142
|
+
});
|
|
143
|
+
if (marksheetData) {
|
|
144
|
+
const { marksheet } = marksheetData.restricted || {};
|
|
145
|
+
const { marks, ...marksheetRest } = marksheet;
|
|
146
|
+
const index = marks.findIndex(({ question }) => Number(question.id) === Number(questionId));
|
|
147
|
+
const { question, ...markRest } = marks[index];
|
|
148
|
+
const { comments = [], ...questionRest } = question;
|
|
149
|
+
cache.writeQuery({
|
|
150
|
+
query: restricted_1.MARKSHEET,
|
|
151
|
+
variables: { id: marksheetId },
|
|
152
|
+
data: {
|
|
153
|
+
...marksheetData,
|
|
154
|
+
restricted: {
|
|
155
|
+
...marksheetData.restricted,
|
|
156
|
+
marksheet: {
|
|
157
|
+
...marksheetRest,
|
|
158
|
+
marks: [
|
|
159
|
+
...marks.slice(0, index),
|
|
160
|
+
{
|
|
161
|
+
...markRest,
|
|
162
|
+
question: {
|
|
163
|
+
...questionRest,
|
|
164
|
+
comments: (0, exports.updateCommentsOnRemove)(comments, commentId, parentId),
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
...marks.slice(index + 1),
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
exports.updatedRemoveCommentsInMarksheetQuestion = updatedRemoveCommentsInMarksheetQuestion;
|
|
176
|
+
const updatedRemoveCommentsInQuestion = (cache, questionId, commentId, parentId) => {
|
|
177
|
+
const questionData = cache.readQuery({
|
|
178
|
+
variables: { id: questionId },
|
|
179
|
+
query: restricted_1.QUESTION,
|
|
180
|
+
});
|
|
181
|
+
if (questionData) {
|
|
182
|
+
const { question } = questionData.restricted || {};
|
|
183
|
+
const { comments = [], ...questionRest } = question;
|
|
184
|
+
cache.writeQuery({
|
|
185
|
+
query: restricted_1.QUESTION,
|
|
186
|
+
variables: { id: questionId },
|
|
187
|
+
data: {
|
|
188
|
+
...questionData,
|
|
189
|
+
restricted: {
|
|
190
|
+
...questionData.restricted,
|
|
191
|
+
question: {
|
|
192
|
+
...questionRest,
|
|
193
|
+
comments: (0, exports.updateCommentsOnRemove)(comments, commentId, parentId),
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
exports.updatedRemoveCommentsInQuestion = updatedRemoveCommentsInQuestion;
|
|
46
201
|
exports.QUESTION_LIKE = (0, client_1.gql) `
|
|
47
202
|
mutation QuestionLike($questionId: Int!, $like: Int!) {
|
|
48
203
|
restricted {
|
|
@@ -56,16 +211,25 @@ exports.QUESTION_LIKE = (0, client_1.gql) `
|
|
|
56
211
|
}
|
|
57
212
|
}
|
|
58
213
|
`;
|
|
59
|
-
const optimisticQuestionLike = (
|
|
214
|
+
const optimisticQuestionLike = (client, input, marksheetId) => {
|
|
60
215
|
const { questionId, like } = input;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{};
|
|
216
|
+
let question;
|
|
217
|
+
if (marksheetId) {
|
|
218
|
+
const data = client.readQuery({
|
|
219
|
+
variables: { id: marksheetId },
|
|
220
|
+
query: restricted_1.MARKSHEET,
|
|
221
|
+
});
|
|
222
|
+
const { marksheet } = data?.restricted || {};
|
|
223
|
+
const { marks = [] } = marksheet || {};
|
|
224
|
+
question = marks.find(({ question }) => Number(question.id) === Number(questionId))?.question;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
const data = client.readQuery({
|
|
228
|
+
variables: { id: Number(questionId) },
|
|
229
|
+
query: restricted_1.QUESTION,
|
|
230
|
+
});
|
|
231
|
+
question = data?.restricted.question;
|
|
232
|
+
}
|
|
69
233
|
if (question) {
|
|
70
234
|
const { typeId } = question;
|
|
71
235
|
return {
|
|
@@ -131,50 +295,11 @@ const updateQuestionComments = (marksheetId) => (cache, result, options) => {
|
|
|
131
295
|
}
|
|
132
296
|
const { questionId, parentId } = variables;
|
|
133
297
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const { marksheet } = prevData.restricted || {};
|
|
140
|
-
const { marks, ...marksheetRest } = marksheet;
|
|
141
|
-
const index = marks.findIndex(({ question }) => Number(question.id) === Number(questionId));
|
|
142
|
-
const { question, ...markRest } = marks[index];
|
|
143
|
-
const { comments = [], ...questionRest } = question;
|
|
144
|
-
let newComments;
|
|
145
|
-
if (parentId) {
|
|
146
|
-
const commentIndex = comments.findIndex(({ id }) => Number(id) === parentId);
|
|
147
|
-
const { replies = [], ...commentRest } = comments[commentIndex];
|
|
148
|
-
newComments = [
|
|
149
|
-
...comments.slice(0, commentIndex),
|
|
150
|
-
{ ...commentRest, replies: [...replies, questionComments] },
|
|
151
|
-
...comments.slice(commentIndex + 1),
|
|
152
|
-
];
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
newComments = [...comments, questionComments];
|
|
156
|
-
}
|
|
157
|
-
cache.writeQuery({
|
|
158
|
-
query: restricted_1.MARKSHEET,
|
|
159
|
-
variables: { id: marksheetId },
|
|
160
|
-
data: {
|
|
161
|
-
...prevData,
|
|
162
|
-
restricted: {
|
|
163
|
-
...prevData.restricted,
|
|
164
|
-
marksheet: {
|
|
165
|
-
...marksheetRest,
|
|
166
|
-
marks: [
|
|
167
|
-
...marks.slice(0, index),
|
|
168
|
-
{
|
|
169
|
-
...markRest,
|
|
170
|
-
question: { ...questionRest, comments: newComments },
|
|
171
|
-
},
|
|
172
|
-
...marks.slice(index + 1),
|
|
173
|
-
],
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
});
|
|
298
|
+
if (marksheetId) {
|
|
299
|
+
(0, exports.updatedCommentsInMarksheetQuestion)(cache, questionComments, marksheetId, questionId, parentId);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
(0, exports.updatedCommentsInQuestion)(cache, questionComments, questionId, parentId);
|
|
178
303
|
}
|
|
179
304
|
}
|
|
180
305
|
catch (error) {
|
|
@@ -299,53 +424,11 @@ const updateQuestionCommentsRemove = (marksheetId) => (cache, result, options) =
|
|
|
299
424
|
}
|
|
300
425
|
const { questionId, id: commentId, parentId } = questionCommentRemove;
|
|
301
426
|
try {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const { marksheet } = prevData.restricted || {};
|
|
308
|
-
const { marks, ...marksheetRest } = marksheet;
|
|
309
|
-
const index = marks.findIndex(({ question }) => Number(question.id) === Number(questionId));
|
|
310
|
-
const { question, ...markRest } = marks[index];
|
|
311
|
-
const { comments = [], ...questionRest } = question;
|
|
312
|
-
let newComments;
|
|
313
|
-
if (parentId) {
|
|
314
|
-
const commentIndex = comments.findIndex(({ id }) => Number(id) === Number(parentId));
|
|
315
|
-
const { replies = [], ...commentRest } = comments[commentIndex];
|
|
316
|
-
newComments = [
|
|
317
|
-
...comments.slice(0, commentIndex),
|
|
318
|
-
{
|
|
319
|
-
...commentRest,
|
|
320
|
-
replies: replies.filter(({ id }) => Number(id) !== Number(commentId)),
|
|
321
|
-
},
|
|
322
|
-
...comments.slice(commentIndex + 1),
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
newComments = comments.filter(({ id }) => Number(id) !== Number(commentId));
|
|
327
|
-
}
|
|
328
|
-
cache.writeQuery({
|
|
329
|
-
query: restricted_1.MARKSHEET,
|
|
330
|
-
variables: { id: marksheetId },
|
|
331
|
-
data: {
|
|
332
|
-
...prevData,
|
|
333
|
-
restricted: {
|
|
334
|
-
...prevData.restricted,
|
|
335
|
-
marksheet: {
|
|
336
|
-
...marksheetRest,
|
|
337
|
-
marks: [
|
|
338
|
-
...marks.slice(0, index),
|
|
339
|
-
{
|
|
340
|
-
...markRest,
|
|
341
|
-
question: { ...questionRest, comments: newComments },
|
|
342
|
-
},
|
|
343
|
-
...marks.slice(index + 1),
|
|
344
|
-
],
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
});
|
|
427
|
+
if (marksheetId) {
|
|
428
|
+
(0, exports.updatedRemoveCommentsInMarksheetQuestion)(cache, marksheetId, questionId, commentId, parentId);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
(0, exports.updatedRemoveCommentsInQuestion)(cache, questionId, commentId, parentId);
|
|
349
432
|
}
|
|
350
433
|
}
|
|
351
434
|
catch (error) {
|