@quesmed/types 2.6.17 → 2.6.19
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/models/MockTest.d.ts +1 -0
- package/dist/cjs/resolvers/fragments/mockTest.js +1 -0
- package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.js +12 -2
- package/dist/mjs/models/MockTest.d.ts +1 -0
- package/dist/mjs/resolvers/fragments/mockTest.js +1 -0
- package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.js +12 -2
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateQuestionHighlights = exports.ADD_QUESTION_HIGHLIGHT = 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.getQuestionHighlightsFragment = exports.getLikeData = exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS = exports.QUESTION_MULTIA_COMMENT_FIELDS = exports.QUESTION_RANKING_HIGHLIGHT_FIELDS = exports.QUESTION_SELECT3_HIGHLIGHT_FIELDS = exports.QUESTION_EMQ_HIGHLIGHT_FIELDS = exports.QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS = exports.QUESTION_MULTIA_HIGHLIGHT_FIELDS = exports.QUESTION_SBA_HIGHLIGHT_FIELDS = exports.QUESTION_QA_HIGHLIGHT_FIELDS = exports.QUESTION_RANKING_COMMENT_FIELDS = exports.QUESTION_SELECT3_COMMENT_FIELDS = exports.QUESTION_EMQ_COMMENT_FIELDS = exports.QUESTION_QA_COMMENT_FIELDS = exports.QUESTION_SBA_COMMENT_FIELDS = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
|
+
const luxon_1 = require("luxon");
|
|
5
6
|
const models_1 = require("../../../models");
|
|
6
7
|
exports.QUESTION_SBA_COMMENT_FIELDS = (0, client_1.gql) `
|
|
7
8
|
fragment QuestionSBAComments on QuestionSBA {
|
|
@@ -779,7 +780,7 @@ const updateQuestionCommentsRemove = (typeId) => (cache, result, options) => {
|
|
|
779
780
|
if (!variables || !questionCommentRemove) {
|
|
780
781
|
return;
|
|
781
782
|
}
|
|
782
|
-
const { questionId, id: commentId, parentId, userId, user, } = questionCommentRemove;
|
|
783
|
+
const { questionId, id: commentId, parentId, userId, user, createdAt, } = questionCommentRemove;
|
|
783
784
|
try {
|
|
784
785
|
const dataFragment = cache.readFragment({
|
|
785
786
|
id: cache.identify({
|
|
@@ -790,6 +791,15 @@ const updateQuestionCommentsRemove = (typeId) => (cache, result, options) => {
|
|
|
790
791
|
});
|
|
791
792
|
if (dataFragment) {
|
|
792
793
|
const { comments = [] } = dataFragment;
|
|
794
|
+
const createdAtDate = luxon_1.DateTime.fromJSDate(createdAt);
|
|
795
|
+
const diffInHours = luxon_1.DateTime.now().diff(createdAtDate, 'hours').hours;
|
|
796
|
+
let updatedComments = [];
|
|
797
|
+
if (diffInHours >= 24) {
|
|
798
|
+
updatedComments = updateCommentFromDiscussion(comments, commentId, { userId, user }, parentId);
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
updatedComments = removeCommnetFromDiscussion(comments, commentId, parentId);
|
|
802
|
+
}
|
|
793
803
|
cache.writeFragment({
|
|
794
804
|
id: cache.identify({
|
|
795
805
|
id: questionId,
|
|
@@ -797,7 +807,7 @@ const updateQuestionCommentsRemove = (typeId) => (cache, result, options) => {
|
|
|
797
807
|
}),
|
|
798
808
|
data: {
|
|
799
809
|
...dataFragment,
|
|
800
|
-
comments:
|
|
810
|
+
comments: updatedComments,
|
|
801
811
|
},
|
|
802
812
|
fragment: getQuestionFragment(typeId),
|
|
803
813
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
|
+
import { DateTime } from 'luxon';
|
|
2
3
|
import { EQuestionLike, EQuestionType, } from '../../../models';
|
|
3
4
|
export const QUESTION_SBA_COMMENT_FIELDS = gql `
|
|
4
5
|
fragment QuestionSBAComments on QuestionSBA {
|
|
@@ -769,7 +770,7 @@ export const updateQuestionCommentsRemove = (typeId) => (cache, result, options)
|
|
|
769
770
|
if (!variables || !questionCommentRemove) {
|
|
770
771
|
return;
|
|
771
772
|
}
|
|
772
|
-
const { questionId, id: commentId, parentId, userId, user, } = questionCommentRemove;
|
|
773
|
+
const { questionId, id: commentId, parentId, userId, user, createdAt, } = questionCommentRemove;
|
|
773
774
|
try {
|
|
774
775
|
const dataFragment = cache.readFragment({
|
|
775
776
|
id: cache.identify({
|
|
@@ -780,6 +781,15 @@ export const updateQuestionCommentsRemove = (typeId) => (cache, result, options)
|
|
|
780
781
|
});
|
|
781
782
|
if (dataFragment) {
|
|
782
783
|
const { comments = [] } = dataFragment;
|
|
784
|
+
const createdAtDate = DateTime.fromJSDate(createdAt);
|
|
785
|
+
const diffInHours = DateTime.now().diff(createdAtDate, 'hours').hours;
|
|
786
|
+
let updatedComments = [];
|
|
787
|
+
if (diffInHours >= 24) {
|
|
788
|
+
updatedComments = updateCommentFromDiscussion(comments, commentId, { userId, user }, parentId);
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
updatedComments = removeCommnetFromDiscussion(comments, commentId, parentId);
|
|
792
|
+
}
|
|
783
793
|
cache.writeFragment({
|
|
784
794
|
id: cache.identify({
|
|
785
795
|
id: questionId,
|
|
@@ -787,7 +797,7 @@ export const updateQuestionCommentsRemove = (typeId) => (cache, result, options)
|
|
|
787
797
|
}),
|
|
788
798
|
data: {
|
|
789
799
|
...dataFragment,
|
|
790
|
-
comments:
|
|
800
|
+
comments: updatedComments,
|
|
791
801
|
},
|
|
792
802
|
fragment: getQuestionFragment(typeId),
|
|
793
803
|
});
|