@quesmed/types 2.2.91 → 2.2.93
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/dist/cjs/resolvers/fragments/marksheet.js +2 -0
- package/dist/cjs/resolvers/mutation/restricted/marksheet.js +24 -0
- package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.d.ts +9 -3
- package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.js +184 -101
- package/dist/cjs/resolvers/query/restricted/marksheet.js +26 -0
- package/dist/cjs/resolvers/query/restricted/question.js +8 -0
- package/dist/mjs/resolvers/fragments/marksheet.js +2 -0
- package/dist/mjs/resolvers/mutation/restricted/marksheet.js +24 -0
- package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.d.ts +9 -3
- package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.js +178 -101
- package/dist/mjs/resolvers/query/restricted/marksheet.js +26 -0
- package/dist/mjs/resolvers/query/restricted/question.js +8 -0
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ exports.MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
|
|
|
47
47
|
id
|
|
48
48
|
createdAt
|
|
49
49
|
comment
|
|
50
|
+
parentId
|
|
50
51
|
likes
|
|
51
52
|
user {
|
|
52
53
|
id
|
|
@@ -59,6 +60,7 @@ exports.MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
|
|
|
59
60
|
id
|
|
60
61
|
createdAt
|
|
61
62
|
comment
|
|
63
|
+
parentId
|
|
62
64
|
user {
|
|
63
65
|
id
|
|
64
66
|
displayName
|
|
@@ -91,6 +91,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
91
91
|
createdAt
|
|
92
92
|
comment
|
|
93
93
|
likes
|
|
94
|
+
parentId
|
|
94
95
|
user {
|
|
95
96
|
id
|
|
96
97
|
displayName
|
|
@@ -101,6 +102,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
101
102
|
replies {
|
|
102
103
|
id
|
|
103
104
|
createdAt
|
|
105
|
+
parentId
|
|
104
106
|
comment
|
|
105
107
|
user {
|
|
106
108
|
id
|
|
@@ -207,6 +209,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
207
209
|
id
|
|
208
210
|
createdAt
|
|
209
211
|
comment
|
|
212
|
+
parentId
|
|
210
213
|
likes
|
|
211
214
|
user {
|
|
212
215
|
id
|
|
@@ -219,6 +222,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
219
222
|
id
|
|
220
223
|
createdAt
|
|
221
224
|
comment
|
|
225
|
+
parentId
|
|
222
226
|
user {
|
|
223
227
|
id
|
|
224
228
|
displayName
|
|
@@ -327,6 +331,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
327
331
|
id
|
|
328
332
|
createdAt
|
|
329
333
|
comment
|
|
334
|
+
parentId
|
|
330
335
|
likes
|
|
331
336
|
user {
|
|
332
337
|
id
|
|
@@ -339,6 +344,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
339
344
|
id
|
|
340
345
|
createdAt
|
|
341
346
|
comment
|
|
347
|
+
parentId
|
|
342
348
|
user {
|
|
343
349
|
id
|
|
344
350
|
displayName
|
|
@@ -444,6 +450,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
444
450
|
id
|
|
445
451
|
createdAt
|
|
446
452
|
comment
|
|
453
|
+
parentId
|
|
447
454
|
likes
|
|
448
455
|
user {
|
|
449
456
|
id
|
|
@@ -456,6 +463,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
456
463
|
id
|
|
457
464
|
createdAt
|
|
458
465
|
comment
|
|
466
|
+
parentId
|
|
459
467
|
user {
|
|
460
468
|
id
|
|
461
469
|
displayName
|
|
@@ -656,6 +664,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
656
664
|
id
|
|
657
665
|
createdAt
|
|
658
666
|
comment
|
|
667
|
+
parentId
|
|
659
668
|
likes
|
|
660
669
|
user {
|
|
661
670
|
id
|
|
@@ -668,6 +677,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
668
677
|
id
|
|
669
678
|
createdAt
|
|
670
679
|
comment
|
|
680
|
+
parentId
|
|
671
681
|
user {
|
|
672
682
|
id
|
|
673
683
|
displayName
|
|
@@ -773,6 +783,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
773
783
|
id
|
|
774
784
|
createdAt
|
|
775
785
|
comment
|
|
786
|
+
parentId
|
|
776
787
|
likes
|
|
777
788
|
user {
|
|
778
789
|
id
|
|
@@ -785,6 +796,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
785
796
|
id
|
|
786
797
|
createdAt
|
|
787
798
|
comment
|
|
799
|
+
parentId
|
|
788
800
|
user {
|
|
789
801
|
id
|
|
790
802
|
displayName
|
|
@@ -893,6 +905,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
893
905
|
id
|
|
894
906
|
createdAt
|
|
895
907
|
comment
|
|
908
|
+
parentId
|
|
896
909
|
likes
|
|
897
910
|
user {
|
|
898
911
|
id
|
|
@@ -905,6 +918,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
905
918
|
id
|
|
906
919
|
createdAt
|
|
907
920
|
comment
|
|
921
|
+
parentId
|
|
908
922
|
user {
|
|
909
923
|
id
|
|
910
924
|
displayName
|
|
@@ -1010,6 +1024,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1010
1024
|
id
|
|
1011
1025
|
createdAt
|
|
1012
1026
|
comment
|
|
1027
|
+
parentId
|
|
1013
1028
|
likes
|
|
1014
1029
|
user {
|
|
1015
1030
|
id
|
|
@@ -1022,6 +1037,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1022
1037
|
id
|
|
1023
1038
|
createdAt
|
|
1024
1039
|
comment
|
|
1040
|
+
parentId
|
|
1025
1041
|
user {
|
|
1026
1042
|
id
|
|
1027
1043
|
displayName
|
|
@@ -1227,6 +1243,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1227
1243
|
id
|
|
1228
1244
|
createdAt
|
|
1229
1245
|
comment
|
|
1246
|
+
parentId
|
|
1230
1247
|
likes
|
|
1231
1248
|
user {
|
|
1232
1249
|
id
|
|
@@ -1239,6 +1256,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1239
1256
|
id
|
|
1240
1257
|
createdAt
|
|
1241
1258
|
comment
|
|
1259
|
+
parentId
|
|
1242
1260
|
user {
|
|
1243
1261
|
id
|
|
1244
1262
|
displayName
|
|
@@ -1344,6 +1362,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1344
1362
|
id
|
|
1345
1363
|
createdAt
|
|
1346
1364
|
comment
|
|
1365
|
+
parentId
|
|
1347
1366
|
likes
|
|
1348
1367
|
user {
|
|
1349
1368
|
id
|
|
@@ -1356,6 +1375,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1356
1375
|
id
|
|
1357
1376
|
createdAt
|
|
1358
1377
|
comment
|
|
1378
|
+
parentId
|
|
1359
1379
|
user {
|
|
1360
1380
|
id
|
|
1361
1381
|
displayName
|
|
@@ -1464,6 +1484,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1464
1484
|
id
|
|
1465
1485
|
createdAt
|
|
1466
1486
|
comment
|
|
1487
|
+
parentId
|
|
1467
1488
|
likes
|
|
1468
1489
|
user {
|
|
1469
1490
|
id
|
|
@@ -1476,6 +1497,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1476
1497
|
id
|
|
1477
1498
|
createdAt
|
|
1478
1499
|
comment
|
|
1500
|
+
parentId
|
|
1479
1501
|
user {
|
|
1480
1502
|
id
|
|
1481
1503
|
displayName
|
|
@@ -1581,6 +1603,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1581
1603
|
id
|
|
1582
1604
|
createdAt
|
|
1583
1605
|
comment
|
|
1606
|
+
parentId
|
|
1584
1607
|
likes
|
|
1585
1608
|
user {
|
|
1586
1609
|
id
|
|
@@ -1593,6 +1616,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1593
1616
|
id
|
|
1594
1617
|
createdAt
|
|
1595
1618
|
comment
|
|
1619
|
+
parentId
|
|
1596
1620
|
user {
|
|
1597
1621
|
id
|
|
1598
1622
|
displayName
|
|
@@ -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) {
|