@quesmed/types 2.2.93 → 2.2.94

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.
@@ -35,7 +35,7 @@ export interface IQuestionCommentsVar {
35
35
  }
36
36
  export declare type IQuestionCommentsData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionComments'>;
37
37
  export declare const QUESTION_COMMENT_LIKE: import("@apollo/client").DocumentNode;
38
- export declare const optimisticCommentLike: (comments: IQuestionComment[], input: IQuestionCommentsLikeVar) => IQuestionCommentsLikeData;
38
+ export declare const optimisticCommentLike: (comments: IQuestionComment[], input: IQuestionCommentsLikeVar, parentId: number | null) => IQuestionCommentsLikeData;
39
39
  export interface IQuestionCommentsLikeVar {
40
40
  commentId: Id;
41
41
  like: EQuestionLike;
@@ -366,15 +366,19 @@ exports.QUESTION_COMMENT_LIKE = (0, client_1.gql) `
366
366
  }
367
367
  }
368
368
  `;
369
- const optimisticCommentLike = (comments, input) => {
369
+ const optimisticCommentLike = (comments, input, parentId) => {
370
370
  const { commentId, like } = input;
371
- const comment = comments.find(({ id }) => Number(id) === Number(commentId)) ||
371
+ const topLevelComment = comments.find(({ id }) => Number(id) === Number(parentId || commentId)) ||
372
372
  {};
373
+ const comment = parentId && topLevelComment.replies
374
+ ? topLevelComment.replies.find(({ id }) => Number(id) === Number(commentId)) || {}
375
+ : topLevelComment;
373
376
  return {
374
377
  restricted: {
375
378
  questionCommentLike: {
376
379
  ...comment,
377
- parentId: comment.parentId ? comment.parentId : 0,
380
+ replies: parentId ? [] : comment.replies,
381
+ id: Number(comment.id),
378
382
  __typename: 'QuestionComment',
379
383
  ...(0, exports.getLikeData)(like, comment),
380
384
  },
@@ -35,7 +35,7 @@ export interface IQuestionCommentsVar {
35
35
  }
36
36
  export declare type IQuestionCommentsData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionComments'>;
37
37
  export declare const QUESTION_COMMENT_LIKE: import("@apollo/client").DocumentNode;
38
- export declare const optimisticCommentLike: (comments: IQuestionComment[], input: IQuestionCommentsLikeVar) => IQuestionCommentsLikeData;
38
+ export declare const optimisticCommentLike: (comments: IQuestionComment[], input: IQuestionCommentsLikeVar, parentId: number | null) => IQuestionCommentsLikeData;
39
39
  export interface IQuestionCommentsLikeVar {
40
40
  commentId: Id;
41
41
  like: EQuestionLike;
@@ -352,15 +352,19 @@ export const QUESTION_COMMENT_LIKE = gql `
352
352
  }
353
353
  }
354
354
  `;
355
- export const optimisticCommentLike = (comments, input) => {
355
+ export const optimisticCommentLike = (comments, input, parentId) => {
356
356
  const { commentId, like } = input;
357
- const comment = comments.find(({ id }) => Number(id) === Number(commentId)) ||
357
+ const topLevelComment = comments.find(({ id }) => Number(id) === Number(parentId || commentId)) ||
358
358
  {};
359
+ const comment = parentId && topLevelComment.replies
360
+ ? topLevelComment.replies.find(({ id }) => Number(id) === Number(commentId)) || {}
361
+ : topLevelComment;
359
362
  return {
360
363
  restricted: {
361
364
  questionCommentLike: {
362
365
  ...comment,
363
- parentId: comment.parentId ? comment.parentId : 0,
366
+ replies: parentId ? [] : comment.replies,
367
+ id: Number(comment.id),
364
368
  __typename: 'QuestionComment',
365
369
  ...getLikeData(like, comment),
366
370
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.2.93",
3
+ "version": "2.2.94",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",