@quesmed/types-rn 2.6.65 → 2.6.67

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.6.65",
3
+ "version": "2.6.67",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -1,3 +1,4 @@
1
1
  export declare const VIDEO_FILE_FIELDS: import("@apollo/client").DocumentNode;
2
2
  export declare const VIDEO_FIELDS: import("@apollo/client").DocumentNode;
3
3
  export declare const VIDEO_STATUS_FRAGMENT: import("@apollo/client").DocumentNode;
4
+ export declare const VIDEO_USER_VIEWED_FRAGMENT: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VIDEO_STATUS_FRAGMENT = exports.VIDEO_FIELDS = exports.VIDEO_FILE_FIELDS = void 0;
3
+ exports.VIDEO_USER_VIEWED_FRAGMENT = exports.VIDEO_STATUS_FRAGMENT = exports.VIDEO_FIELDS = exports.VIDEO_FILE_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  exports.VIDEO_FILE_FIELDS = (0, client_1.gql) `
6
6
  fragment VideoFileFields on File {
@@ -50,3 +50,8 @@ exports.VIDEO_STATUS_FRAGMENT = (0, client_1.gql) `
50
50
  status
51
51
  }
52
52
  `;
53
+ exports.VIDEO_USER_VIEWED_FRAGMENT = (0, client_1.gql) `
54
+ fragment VideoUserViewed on Video {
55
+ userViewed
56
+ }
57
+ `;
@@ -29,3 +29,25 @@ export interface IAddChapterHighlightVar {
29
29
  export type IAddChapterHighlightData = RestrictedData<(graphqlNormalize & IChapterHighlight)[], 'addChapterHighlight'>;
30
30
  export declare const ADD_CHAPTER_HIGHLIGHT: import("@apollo/client").DocumentNode;
31
31
  export declare const updateChapterHighlights: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddChapterHighlightData>, options: ApolloUpdateOptions<IAddChapterHighlightVar>) => void;
32
+ export declare const getChapterHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], chapterId: number) => {
33
+ restricted: {
34
+ addChapterHighlight: {
35
+ chapterId: number;
36
+ id: number;
37
+ userId: number;
38
+ createdAt: number;
39
+ updatedAt: number;
40
+ deletedAt: number;
41
+ highlights: {
42
+ start: number;
43
+ end: number;
44
+ text: string;
45
+ color: string;
46
+ part?: string | undefined;
47
+ tag: string;
48
+ __typename: string;
49
+ }[];
50
+ __typename: string;
51
+ }[];
52
+ };
53
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateChapterHighlights = exports.ADD_CHAPTER_HIGHLIGHT = exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
3
+ exports.getChapterHighlightOptimisticResponse = exports.updateChapterHighlights = exports.ADD_CHAPTER_HIGHLIGHT = exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const fragments_1 = require("../../fragments");
6
6
  /**
@@ -96,3 +96,28 @@ const updateChapterHighlights = (cache, result, options) => {
96
96
  }
97
97
  };
98
98
  exports.updateChapterHighlights = updateChapterHighlights;
99
+ const getChapterHighlightOptimisticResponse = (userId, highlights, chapterId) => {
100
+ const date = new Date().getTime();
101
+ return {
102
+ restricted: {
103
+ addChapterHighlight: [
104
+ {
105
+ chapterId,
106
+ id: date,
107
+ userId,
108
+ createdAt: date,
109
+ updatedAt: date,
110
+ deletedAt: date,
111
+ highlights: highlights.map((highlight) => ({
112
+ __typename: 'HighlightNode',
113
+ tag: '',
114
+ color: '',
115
+ ...highlight,
116
+ })),
117
+ __typename: 'ChapterHighlight',
118
+ },
119
+ ],
120
+ },
121
+ };
122
+ };
123
+ exports.getChapterHighlightOptimisticResponse = getChapterHighlightOptimisticResponse;
@@ -62,4 +62,26 @@ export interface IAddQuestionHighlightVar {
62
62
  export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlight)[], 'addQuestionHighlight'>;
63
63
  export declare const ADD_QUESTION_HIGHLIGHT: import("@apollo/client").DocumentNode;
64
64
  export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions<IAddQuestionHighlightVar>) => void;
65
+ export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
66
+ restricted: {
67
+ addQuestionHighlight: {
68
+ questionId: number;
69
+ id: number;
70
+ userId: number;
71
+ createdAt: number;
72
+ updatedAt: number;
73
+ deletedAt: number;
74
+ highlights: {
75
+ start: number;
76
+ end: number;
77
+ text: string;
78
+ color: string;
79
+ part?: string | undefined;
80
+ tag: string;
81
+ __typename: string;
82
+ }[];
83
+ __typename: string;
84
+ }[];
85
+ };
86
+ };
65
87
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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.getLikeData = void 0;
3
+ exports.getQuestionHighlightOptimisticResponse = 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.getLikeData = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const luxon_1 = require("luxon");
6
6
  const models_1 = require("../../../models");
@@ -378,3 +378,28 @@ const updateQuestionHighlights = (typeId) => (cache, result, options) => {
378
378
  }
379
379
  };
380
380
  exports.updateQuestionHighlights = updateQuestionHighlights;
381
+ const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
382
+ const date = new Date().getTime();
383
+ return {
384
+ restricted: {
385
+ addQuestionHighlight: [
386
+ {
387
+ questionId,
388
+ id: date,
389
+ userId,
390
+ createdAt: date,
391
+ updatedAt: date,
392
+ deletedAt: date,
393
+ highlights: highlights.map((highlight) => ({
394
+ __typename: 'HighlightNode',
395
+ tag: '',
396
+ color: '',
397
+ ...highlight,
398
+ })),
399
+ __typename: 'ChapterHighlight',
400
+ },
401
+ ],
402
+ },
403
+ };
404
+ };
405
+ exports.getQuestionHighlightOptimisticResponse = getQuestionHighlightOptimisticResponse;
@@ -1,7 +1,10 @@
1
- import { Id, IVideo } from '../../../models';
2
- import { graphqlNormalize, RestrictedData } from '../../types';
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { IVideo, Id } from '../../../models';
3
+ import { ApolloUpdateResultRestricted } from '../../apollo';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
3
5
  export declare const VIDEO_WATCHED: import("@apollo/client").DocumentNode;
4
6
  export interface IVideoWatchedVar {
5
7
  id: Id;
6
8
  }
7
9
  export type IVideoWatchedData = RestrictedData<graphqlNormalize & IVideo, 'videoWatched'>;
10
+ export declare const updateCacheOnVideoWatched: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VIDEO_WATCHED = void 0;
3
+ exports.updateCacheOnVideoWatched = exports.VIDEO_WATCHED = void 0;
4
4
  const client_1 = require("@apollo/client");
5
+ const fragments_1 = require("../../fragments");
5
6
  exports.VIDEO_WATCHED = (0, client_1.gql) `
6
7
  mutation VideoWatched($id: Int!) {
7
8
  restricted {
@@ -13,3 +14,18 @@ exports.VIDEO_WATCHED = (0, client_1.gql) `
13
14
  }
14
15
  }
15
16
  `;
17
+ const updateCacheOnVideoWatched = (cache, result) => {
18
+ const { videoWatched } = result?.data?.restricted || {};
19
+ if (!videoWatched) {
20
+ return;
21
+ }
22
+ const { id } = videoWatched;
23
+ cache.writeFragment({
24
+ id: cache.identify({ id, __typename: 'Video' }),
25
+ data: {
26
+ userViewed: true,
27
+ },
28
+ fragment: fragments_1.VIDEO_USER_VIEWED_FRAGMENT,
29
+ });
30
+ };
31
+ exports.updateCacheOnVideoWatched = updateCacheOnVideoWatched;