@quesmed/types-rn 2.6.14 → 2.6.16
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/models/Topic.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -512,6 +512,28 @@ const removeCommnetFromDiscussion = (comments, commentId, parentId) => {
|
|
|
512
512
|
}
|
|
513
513
|
return comments.filter(({ id }) => Number(id) !== Number(commentId));
|
|
514
514
|
};
|
|
515
|
+
const updateCommentFromDiscussion = (comments, commentId, update, parentId) => {
|
|
516
|
+
const updatedComments = [...comments];
|
|
517
|
+
if (parentId) {
|
|
518
|
+
const parentIndex = comments.findIndex((comment) => Number(comment.id) === Number(parentId));
|
|
519
|
+
if (parentIndex !== -1) {
|
|
520
|
+
const parentComment = updatedComments[parentIndex];
|
|
521
|
+
parentComment.replies = (parentComment.replies ?? []).map((reply) => Number(reply.id) === Number(commentId)
|
|
522
|
+
? { ...reply, ...update }
|
|
523
|
+
: reply);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
const commentIndex = comments.findIndex((comment) => Number(comment.id) === Number(commentId));
|
|
528
|
+
if (commentIndex !== -1) {
|
|
529
|
+
updatedComments[commentIndex] = {
|
|
530
|
+
...updatedComments[commentIndex],
|
|
531
|
+
...update,
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return updatedComments;
|
|
536
|
+
};
|
|
515
537
|
exports.QUESTION_LIKE = (0, client_1.gql) `
|
|
516
538
|
mutation QuestionLike($marksheetId: Int, $questionId: Int!, $like: Int!) {
|
|
517
539
|
restricted {
|
|
@@ -757,7 +779,7 @@ const updateQuestionCommentsRemove = (typeId) => (cache, result, options) => {
|
|
|
757
779
|
if (!variables || !questionCommentRemove) {
|
|
758
780
|
return;
|
|
759
781
|
}
|
|
760
|
-
const { questionId, id: commentId, parentId } = questionCommentRemove;
|
|
782
|
+
const { questionId, id: commentId, parentId, userId, user, } = questionCommentRemove;
|
|
761
783
|
try {
|
|
762
784
|
const dataFragment = cache.readFragment({
|
|
763
785
|
id: cache.identify({
|
|
@@ -775,7 +797,7 @@ const updateQuestionCommentsRemove = (typeId) => (cache, result, options) => {
|
|
|
775
797
|
}),
|
|
776
798
|
data: {
|
|
777
799
|
...dataFragment,
|
|
778
|
-
comments:
|
|
800
|
+
comments: updateCommentFromDiscussion(comments, commentId, { userId, user }, parentId),
|
|
779
801
|
},
|
|
780
802
|
fragment: getQuestionFragment(typeId),
|
|
781
803
|
});
|