@quesmed/types-rn 2.2.94 → 2.2.95
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,4 +1,4 @@
|
|
|
1
|
-
import { ApolloCache,
|
|
1
|
+
import { ApolloCache, DocumentNode } from '@apollo/client';
|
|
2
2
|
import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
|
|
3
3
|
import { EQuestionLike, EQuestionType, Id, IQuestion, IQuestionComment } from '../../../models';
|
|
4
4
|
import { graphqlNormalize, RestrictedData } from '../../types';
|
|
@@ -7,23 +7,21 @@ interface LikeData {
|
|
|
7
7
|
dislikes?: number;
|
|
8
8
|
isLikedByMe?: EQuestionLike;
|
|
9
9
|
}
|
|
10
|
+
export declare const QUESTION_SBA_COMMENT_FIELDS: DocumentNode;
|
|
11
|
+
export declare const QUESTION_QA_COMMENT_FIELDS: DocumentNode;
|
|
12
|
+
export declare const QUESTION_MULTIA_COMMENT_FIELDS: DocumentNode;
|
|
13
|
+
export declare const QUESTION_PRESCRIPTION_COMMENT_FIELDS: DocumentNode;
|
|
10
14
|
export declare const getLikeData: (like: EQuestionLike, item: LikeData) => LikeData;
|
|
11
15
|
export declare const getQuestionTypeName: (typeId: EQuestionType) => string;
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
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;
|
|
18
|
-
export declare const QUESTION_LIKE: import("@apollo/client").DocumentNode;
|
|
19
|
-
export declare const optimisticQuestionLike: (client: ApolloClient<any>, input: IQuestionLikeVar, marksheetId?: number | undefined) => IQuestionLikeData;
|
|
16
|
+
export declare const QUESTION_LIKE: DocumentNode;
|
|
17
|
+
export declare const optimisticQuestionLike: (input: IQuestionLikeVar, question: IQuestion) => IQuestionLikeData;
|
|
20
18
|
export interface IQuestionLikeVar {
|
|
21
19
|
questionId: Id;
|
|
22
20
|
like: EQuestionLike;
|
|
23
21
|
}
|
|
24
22
|
export declare type IQuestionLikeData = RestrictedData<graphqlNormalize & IQuestion, 'questionLike'>;
|
|
25
|
-
export declare const QUESTION_COMMENTS:
|
|
26
|
-
export declare const updateQuestionComments: (
|
|
23
|
+
export declare const QUESTION_COMMENTS: DocumentNode;
|
|
24
|
+
export declare const updateQuestionComments: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IQuestionCommentsData>, options: ApolloUpdateOptions) => void;
|
|
27
25
|
export declare const optimisticQuestionComment: (id: number, user: {
|
|
28
26
|
id: number;
|
|
29
27
|
displayName: string;
|
|
@@ -34,15 +32,15 @@ export interface IQuestionCommentsVar {
|
|
|
34
32
|
comment: string;
|
|
35
33
|
}
|
|
36
34
|
export declare type IQuestionCommentsData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionComments'>;
|
|
37
|
-
export declare const QUESTION_COMMENT_LIKE:
|
|
35
|
+
export declare const QUESTION_COMMENT_LIKE: DocumentNode;
|
|
38
36
|
export declare const optimisticCommentLike: (comments: IQuestionComment[], input: IQuestionCommentsLikeVar, parentId: number | null) => IQuestionCommentsLikeData;
|
|
39
37
|
export interface IQuestionCommentsLikeVar {
|
|
40
38
|
commentId: Id;
|
|
41
39
|
like: EQuestionLike;
|
|
42
40
|
}
|
|
43
41
|
export declare type IQuestionCommentsLikeData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionCommentLike'>;
|
|
44
|
-
export declare const QUESTION_COMMENT_REMOVE:
|
|
45
|
-
export declare const updateQuestionCommentsRemove: (
|
|
42
|
+
export declare const QUESTION_COMMENT_REMOVE: DocumentNode;
|
|
43
|
+
export declare const updateQuestionCommentsRemove: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IQuestionCommentRemoveData>, options: ApolloUpdateOptions) => void;
|
|
46
44
|
export declare const optimisticQuestionCommentRemove: (comments: IQuestionComment[], input: IQuestionCommentRemoveVar, parentId?: number | undefined) => IQuestionCommentRemoveData;
|
|
47
45
|
export interface IQuestionCommentRemoveVar {
|
|
48
46
|
commentId: Id;
|
|
@@ -1,9 +1,152 @@
|
|
|
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.
|
|
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 = exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS = exports.QUESTION_MULTIA_COMMENT_FIELDS = exports.QUESTION_QA_COMMENT_FIELDS = exports.QUESTION_SBA_COMMENT_FIELDS = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
const models_1 = require("../../../models");
|
|
6
|
-
|
|
6
|
+
exports.QUESTION_SBA_COMMENT_FIELDS = (0, client_1.gql) `
|
|
7
|
+
fragment QuestionSBAComments on QuestionSBA {
|
|
8
|
+
id
|
|
9
|
+
likes
|
|
10
|
+
dislikes
|
|
11
|
+
isLikedByMe
|
|
12
|
+
comments {
|
|
13
|
+
id
|
|
14
|
+
createdAt
|
|
15
|
+
comment
|
|
16
|
+
parentId
|
|
17
|
+
likes
|
|
18
|
+
user {
|
|
19
|
+
id
|
|
20
|
+
displayName
|
|
21
|
+
}
|
|
22
|
+
dislikes
|
|
23
|
+
isLikedByMe
|
|
24
|
+
questionId
|
|
25
|
+
replies {
|
|
26
|
+
id
|
|
27
|
+
createdAt
|
|
28
|
+
comment
|
|
29
|
+
parentId
|
|
30
|
+
user {
|
|
31
|
+
id
|
|
32
|
+
displayName
|
|
33
|
+
}
|
|
34
|
+
likes
|
|
35
|
+
dislikes
|
|
36
|
+
isLikedByMe
|
|
37
|
+
questionId
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
exports.QUESTION_QA_COMMENT_FIELDS = (0, client_1.gql) `
|
|
43
|
+
fragment QuestionQAComments on QuestionQA {
|
|
44
|
+
id
|
|
45
|
+
likes
|
|
46
|
+
dislikes
|
|
47
|
+
isLikedByMe
|
|
48
|
+
comments {
|
|
49
|
+
id
|
|
50
|
+
createdAt
|
|
51
|
+
comment
|
|
52
|
+
parentId
|
|
53
|
+
likes
|
|
54
|
+
user {
|
|
55
|
+
id
|
|
56
|
+
displayName
|
|
57
|
+
}
|
|
58
|
+
dislikes
|
|
59
|
+
isLikedByMe
|
|
60
|
+
questionId
|
|
61
|
+
replies {
|
|
62
|
+
id
|
|
63
|
+
createdAt
|
|
64
|
+
comment
|
|
65
|
+
parentId
|
|
66
|
+
user {
|
|
67
|
+
id
|
|
68
|
+
displayName
|
|
69
|
+
}
|
|
70
|
+
likes
|
|
71
|
+
dislikes
|
|
72
|
+
isLikedByMe
|
|
73
|
+
questionId
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
exports.QUESTION_MULTIA_COMMENT_FIELDS = (0, client_1.gql) `
|
|
79
|
+
fragment QuestionMultiAComments on QuestionMultiA {
|
|
80
|
+
id
|
|
81
|
+
likes
|
|
82
|
+
dislikes
|
|
83
|
+
isLikedByMe
|
|
84
|
+
comments {
|
|
85
|
+
id
|
|
86
|
+
createdAt
|
|
87
|
+
comment
|
|
88
|
+
parentId
|
|
89
|
+
likes
|
|
90
|
+
user {
|
|
91
|
+
id
|
|
92
|
+
displayName
|
|
93
|
+
}
|
|
94
|
+
dislikes
|
|
95
|
+
isLikedByMe
|
|
96
|
+
questionId
|
|
97
|
+
replies {
|
|
98
|
+
id
|
|
99
|
+
createdAt
|
|
100
|
+
comment
|
|
101
|
+
parentId
|
|
102
|
+
user {
|
|
103
|
+
id
|
|
104
|
+
displayName
|
|
105
|
+
}
|
|
106
|
+
likes
|
|
107
|
+
dislikes
|
|
108
|
+
isLikedByMe
|
|
109
|
+
questionId
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS = (0, client_1.gql) `
|
|
115
|
+
fragment QuestionPrescriptionComments on QuestionPrescription {
|
|
116
|
+
id
|
|
117
|
+
likes
|
|
118
|
+
dislikes
|
|
119
|
+
isLikedByMe
|
|
120
|
+
comments {
|
|
121
|
+
id
|
|
122
|
+
createdAt
|
|
123
|
+
comment
|
|
124
|
+
parentId
|
|
125
|
+
likes
|
|
126
|
+
user {
|
|
127
|
+
id
|
|
128
|
+
displayName
|
|
129
|
+
}
|
|
130
|
+
dislikes
|
|
131
|
+
isLikedByMe
|
|
132
|
+
questionId
|
|
133
|
+
replies {
|
|
134
|
+
id
|
|
135
|
+
createdAt
|
|
136
|
+
comment
|
|
137
|
+
parentId
|
|
138
|
+
user {
|
|
139
|
+
id
|
|
140
|
+
displayName
|
|
141
|
+
}
|
|
142
|
+
likes
|
|
143
|
+
dislikes
|
|
144
|
+
isLikedByMe
|
|
145
|
+
questionId
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
7
150
|
const getLikeData = (like, item) => {
|
|
8
151
|
let { likes = 0, dislikes = 0, isLikedByMe } = item;
|
|
9
152
|
if (isLikedByMe === models_1.EQuestionLike.LIKE) {
|
|
@@ -43,7 +186,20 @@ const getQuestionTypeName = (typeId) => {
|
|
|
43
186
|
}
|
|
44
187
|
};
|
|
45
188
|
exports.getQuestionTypeName = getQuestionTypeName;
|
|
46
|
-
const
|
|
189
|
+
const getQuestionFragment = (typeId) => {
|
|
190
|
+
switch (typeId) {
|
|
191
|
+
case models_1.EQuestionType.QUESTION_ANSWER:
|
|
192
|
+
return exports.QUESTION_QA_COMMENT_FIELDS;
|
|
193
|
+
case models_1.EQuestionType.PRESCRIPTION_ANSWER:
|
|
194
|
+
return exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS;
|
|
195
|
+
case models_1.EQuestionType.MULTIPLE_ANSWERS:
|
|
196
|
+
return exports.QUESTION_MULTIA_COMMENT_FIELDS;
|
|
197
|
+
case models_1.EQuestionType.SINGLE_BEST_ANSWER:
|
|
198
|
+
default:
|
|
199
|
+
return exports.QUESTION_SBA_COMMENT_FIELDS;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const addCommentToDiscussion = (newComment, comments, parentId) => {
|
|
47
203
|
if (parentId) {
|
|
48
204
|
const commentIndex = comments.findIndex(({ id }) => Number(id) === parentId);
|
|
49
205
|
const { replies = [], ...commentRest } = comments[commentIndex];
|
|
@@ -55,8 +211,7 @@ const updatedCommentsOnAdd = (newComment, comments, parentId) => {
|
|
|
55
211
|
}
|
|
56
212
|
return [...comments, newComment];
|
|
57
213
|
};
|
|
58
|
-
|
|
59
|
-
const updateCommentsOnRemove = (comments, commentId, parentId) => {
|
|
214
|
+
const removeCommnetFromDiscussion = (comments, commentId, parentId) => {
|
|
60
215
|
if (parentId) {
|
|
61
216
|
const commentIndex = comments.findIndex(({ id }) => Number(id) === Number(parentId));
|
|
62
217
|
const { replies = [], ...commentRest } = comments[commentIndex];
|
|
@@ -71,133 +226,6 @@ const updateCommentsOnRemove = (comments, commentId, parentId) => {
|
|
|
71
226
|
}
|
|
72
227
|
return comments.filter(({ id }) => Number(id) !== Number(commentId));
|
|
73
228
|
};
|
|
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;
|
|
201
229
|
exports.QUESTION_LIKE = (0, client_1.gql) `
|
|
202
230
|
mutation QuestionLike($questionId: Int!, $like: Int!) {
|
|
203
231
|
restricted {
|
|
@@ -211,38 +239,16 @@ exports.QUESTION_LIKE = (0, client_1.gql) `
|
|
|
211
239
|
}
|
|
212
240
|
}
|
|
213
241
|
`;
|
|
214
|
-
const optimisticQuestionLike = (
|
|
215
|
-
const {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
}
|
|
233
|
-
if (question) {
|
|
234
|
-
const { typeId } = question;
|
|
235
|
-
return {
|
|
236
|
-
restricted: {
|
|
237
|
-
questionLike: {
|
|
238
|
-
...question,
|
|
239
|
-
__typename: (0, exports.getQuestionTypeName)(typeId),
|
|
240
|
-
...(0, exports.getLikeData)(like, question),
|
|
241
|
-
},
|
|
242
|
+
const optimisticQuestionLike = (input, question) => {
|
|
243
|
+
const { like } = input;
|
|
244
|
+
return {
|
|
245
|
+
restricted: {
|
|
246
|
+
questionLike: {
|
|
247
|
+
...question,
|
|
248
|
+
...(0, exports.getLikeData)(like, question),
|
|
242
249
|
},
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return {};
|
|
250
|
+
},
|
|
251
|
+
};
|
|
246
252
|
};
|
|
247
253
|
exports.optimisticQuestionLike = optimisticQuestionLike;
|
|
248
254
|
exports.QUESTION_COMMENTS = (0, client_1.gql) `
|
|
@@ -287,7 +293,7 @@ exports.QUESTION_COMMENTS = (0, client_1.gql) `
|
|
|
287
293
|
}
|
|
288
294
|
}
|
|
289
295
|
`;
|
|
290
|
-
const updateQuestionComments = (
|
|
296
|
+
const updateQuestionComments = (typeId) => (cache, result, options) => {
|
|
291
297
|
const { questionComments } = result?.data?.restricted || {};
|
|
292
298
|
const { variables } = options || {};
|
|
293
299
|
if (!variables || !questionComments) {
|
|
@@ -295,11 +301,26 @@ const updateQuestionComments = (marksheetId) => (cache, result, options) => {
|
|
|
295
301
|
}
|
|
296
302
|
const { questionId, parentId } = variables;
|
|
297
303
|
try {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
const dataFragment = cache.readFragment({
|
|
305
|
+
id: cache.identify({
|
|
306
|
+
id: questionId,
|
|
307
|
+
__typename: (0, exports.getQuestionTypeName)(typeId),
|
|
308
|
+
}),
|
|
309
|
+
fragment: getQuestionFragment(typeId),
|
|
310
|
+
});
|
|
311
|
+
if (dataFragment) {
|
|
312
|
+
const { comments = [] } = dataFragment;
|
|
313
|
+
cache.writeFragment({
|
|
314
|
+
id: cache.identify({
|
|
315
|
+
id: questionId,
|
|
316
|
+
__typename: (0, exports.getQuestionTypeName)(typeId),
|
|
317
|
+
}),
|
|
318
|
+
data: {
|
|
319
|
+
...dataFragment,
|
|
320
|
+
comments: addCommentToDiscussion(questionComments, comments, parentId),
|
|
321
|
+
},
|
|
322
|
+
fragment: getQuestionFragment(typeId),
|
|
323
|
+
});
|
|
303
324
|
}
|
|
304
325
|
}
|
|
305
326
|
catch (error) {
|
|
@@ -420,7 +441,7 @@ exports.QUESTION_COMMENT_REMOVE = (0, client_1.gql) `
|
|
|
420
441
|
}
|
|
421
442
|
}
|
|
422
443
|
`;
|
|
423
|
-
const updateQuestionCommentsRemove = (
|
|
444
|
+
const updateQuestionCommentsRemove = (typeId) => (cache, result, options) => {
|
|
424
445
|
const { questionCommentRemove } = result?.data?.restricted || {};
|
|
425
446
|
const { variables } = options || {};
|
|
426
447
|
if (!variables || !questionCommentRemove) {
|
|
@@ -428,11 +449,26 @@ const updateQuestionCommentsRemove = (marksheetId) => (cache, result, options) =
|
|
|
428
449
|
}
|
|
429
450
|
const { questionId, id: commentId, parentId } = questionCommentRemove;
|
|
430
451
|
try {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
452
|
+
const dataFragment = cache.readFragment({
|
|
453
|
+
id: cache.identify({
|
|
454
|
+
id: questionId,
|
|
455
|
+
__typename: (0, exports.getQuestionTypeName)(typeId),
|
|
456
|
+
}),
|
|
457
|
+
fragment: getQuestionFragment(typeId),
|
|
458
|
+
});
|
|
459
|
+
if (dataFragment) {
|
|
460
|
+
const { comments = [] } = dataFragment;
|
|
461
|
+
cache.writeFragment({
|
|
462
|
+
id: cache.identify({
|
|
463
|
+
id: questionId,
|
|
464
|
+
__typename: (0, exports.getQuestionTypeName)(typeId),
|
|
465
|
+
}),
|
|
466
|
+
data: {
|
|
467
|
+
...dataFragment,
|
|
468
|
+
comments: removeCommnetFromDiscussion(comments, commentId, parentId),
|
|
469
|
+
},
|
|
470
|
+
fragment: getQuestionFragment(typeId),
|
|
471
|
+
});
|
|
436
472
|
}
|
|
437
473
|
}
|
|
438
474
|
catch (error) {
|