@quesmed/types 2.5.14 → 2.5.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.
@@ -3,6 +3,7 @@ import { EDifficultyType } from './Difficulty';
3
3
  import { IPicture } from './Picture';
4
4
  import { ITopic } from './Topic';
5
5
  import { Id } from './Type';
6
+ import { EUserLearningStatus } from './User';
6
7
  import { IVideo } from './Video';
7
8
  export interface IOsceType {
8
9
  id: Id;
@@ -50,6 +51,7 @@ export interface IOsceStation {
50
51
  videos?: IVideo[];
51
52
  lastOsceMarksheetId?: Id;
52
53
  score?: number;
54
+ status?: EUserLearningStatus;
53
55
  }
54
56
  export interface IOsceStationTopic {
55
57
  id: Id;
@@ -19,6 +19,7 @@ exports.OSCE_STATION_FIELDS = (0, client_1.gql) `
19
19
  id
20
20
  updatedAt
21
21
  name
22
+ status
22
23
  osceType {
23
24
  id
24
25
  name
@@ -50,6 +51,7 @@ exports.OSCE_STATION_FIELDS = (0, client_1.gql) `
50
51
  videos {
51
52
  id
52
53
  title
54
+ status
53
55
  museId
54
56
  thumbnail
55
57
  concepts {
@@ -1,5 +1,7 @@
1
- import { EUserLearningStatus, Id, IUser, IUserConceptStatus, IUserStationStatus, IUserVideoStatus } from '../../../models';
2
- import { graphqlNormalize, RestrictedData } from '../../types';
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { EUserLearningStatus, IUser, IUserConceptStatus, IUserStationStatus, IUserVideoStatus, Id } from '../../../models';
3
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
3
5
  export declare const RESET_PROGRESS: import("@apollo/client").DocumentNode;
4
6
  export interface IResetProgressVar {
5
7
  questions?: boolean;
@@ -45,15 +47,18 @@ export type IUpsertUserConceptStatusVar = {
45
47
  };
46
48
  export type IUpsertUserConceptStatusData = RestrictedData<graphqlNormalize & IUserConceptStatus[], 'upsertUserConceptStatus'>;
47
49
  export declare const UPSERT_USER_CONCEPT_STATUS: import("@apollo/client").DocumentNode;
50
+ export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
48
51
  export type IUpsertUserStationStatusVar = {
49
52
  osceStationIds: Id[];
50
53
  status: EUserLearningStatus;
51
54
  };
52
55
  export type IUpsertUserStationStatusData = RestrictedData<graphqlNormalize & IUserStationStatus[], 'upsertUserStationStatus'>;
53
56
  export declare const UPSERT_USER_STATION_STATUS: import("@apollo/client").DocumentNode;
57
+ export declare const updateCacheOnStationLearningStatusUpdate: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserStationStatusData>, options: ApolloUpdateOptions) => void;
54
58
  export type IUpsertUserVideoStatusVar = {
55
59
  videoIds: Id[];
56
60
  status: EUserLearningStatus;
57
61
  };
58
62
  export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
59
63
  export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
64
+ export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null, topicId?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UPSERT_USER_VIDEO_STATUS = exports.UPSERT_USER_STATION_STATUS = exports.UPSERT_USER_CONCEPT_STATUS = exports.TOC_ACCEPT = exports.RENEW_TOKEN = exports.UPDATE_USER = exports.DELETE_USER = exports.RESET_PROGRESS = void 0;
3
+ exports.updateCacheOnVideoLearningStatusUpdate = exports.UPSERT_USER_VIDEO_STATUS = exports.updateCacheOnStationLearningStatusUpdate = exports.UPSERT_USER_STATION_STATUS = exports.updateCacheOnConceptLearningStatusUpdate = exports.UPSERT_USER_CONCEPT_STATUS = exports.TOC_ACCEPT = exports.RENEW_TOKEN = exports.UPDATE_USER = exports.DELETE_USER = exports.RESET_PROGRESS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
+ const models_1 = require("../../../models");
5
6
  exports.RESET_PROGRESS = (0, client_1.gql) `
6
7
  mutation ResetProgress($questions: Boolean, $cards: Boolean) {
7
8
  restricted {
@@ -68,10 +69,88 @@ exports.UPSERT_USER_CONCEPT_STATUS = (0, client_1.gql) `
68
69
  }
69
70
  }
70
71
  `;
72
+ const STATUS_CONCEPT_FRAGMENT = (0, client_1.gql) `
73
+ fragment ConceptStatus on Concept {
74
+ status
75
+ }
76
+ `;
77
+ const TOPIC_CONCEPT_STATUS_STATS_FRAGMENT = (0, client_1.gql) `
78
+ fragment TopicConceptStatusStats on Topic {
79
+ unreadConcepts
80
+ completedConcepts
81
+ revisingConcepts
82
+ urgentConcepts
83
+ }
84
+ `;
85
+ const getConceptStatsFieldName = (status) => {
86
+ switch (status) {
87
+ case models_1.EUserLearningStatus.URGENT:
88
+ return 'urgentConcepts';
89
+ case models_1.EUserLearningStatus.REVISING:
90
+ return 'revisingConcepts';
91
+ case models_1.EUserLearningStatus.COMPLETED:
92
+ return 'completedConcepts';
93
+ case models_1.EUserLearningStatus.UNREAD:
94
+ default:
95
+ return 'unreadConcepts';
96
+ }
97
+ };
98
+ const getConceptUpdatedFieldNames = (newStatus, prevStatus) => [
99
+ getConceptStatsFieldName(prevStatus),
100
+ getConceptStatsFieldName(newStatus),
101
+ ];
102
+ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache, result, options) => {
103
+ const { upsertUserConceptStatus } = result?.data?.restricted || {};
104
+ const { variables } = options || {};
105
+ if (!variables || !upsertUserConceptStatus) {
106
+ return;
107
+ }
108
+ const { conceptIds, status } = variables;
109
+ conceptIds.forEach((id) => {
110
+ cache.writeFragment({
111
+ id: cache.identify({ id, __typename: 'Concept' }),
112
+ data: {
113
+ status,
114
+ },
115
+ fragment: STATUS_CONCEPT_FRAGMENT,
116
+ });
117
+ });
118
+ const prevData = cache.readFragment({
119
+ id: cache.identify({
120
+ id: topicId,
121
+ __typename: 'Topic',
122
+ }),
123
+ fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
124
+ });
125
+ if (prevData) {
126
+ const [prevStatName, newStatName] = getConceptUpdatedFieldNames(status, prevStatus);
127
+ const newData = {
128
+ ...prevData,
129
+ [newStatName]: (prevData[newStatName] || 0) + conceptIds.length,
130
+ };
131
+ if (prevStatus !== undefined &&
132
+ prevStatus !== null &&
133
+ prevData[prevStatName]) {
134
+ newData[prevStatName] =
135
+ (prevData[prevStatName] || 0) - conceptIds.length;
136
+ }
137
+ cache.writeFragment({
138
+ id: cache.identify({ id: topicId, __typename: 'Topic' }),
139
+ data: {
140
+ ...newData,
141
+ },
142
+ fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
143
+ });
144
+ }
145
+ };
146
+ exports.updateCacheOnConceptLearningStatusUpdate = updateCacheOnConceptLearningStatusUpdate;
71
147
  exports.UPSERT_USER_STATION_STATUS = (0, client_1.gql) `
72
148
  mutation UpsertUserStationStatus($osceStationIds: [Int!]!, $status: Int!) {
73
149
  restricted {
74
- upsertUserStationStatus(osceStationIds: $osceStationIds, status: $status) {
150
+ upsertUserStationStatus(
151
+ osceStationIds: $osceStationIds
152
+ status: $status
153
+ ) {
75
154
  id
76
155
  status
77
156
  osceStationId
@@ -81,6 +160,29 @@ exports.UPSERT_USER_STATION_STATUS = (0, client_1.gql) `
81
160
  }
82
161
  }
83
162
  `;
163
+ const STATION_CONCEPT_FRAGMENT = (0, client_1.gql) `
164
+ fragment StationStatus on OsceStation {
165
+ status
166
+ }
167
+ `;
168
+ const updateCacheOnStationLearningStatusUpdate = (cache, result, options) => {
169
+ const { upsertUserStationStatus } = result?.data?.restricted || {};
170
+ const { variables } = options || {};
171
+ if (!variables || !upsertUserStationStatus) {
172
+ return;
173
+ }
174
+ const { osceStationIds, status } = variables;
175
+ osceStationIds.forEach((id) => {
176
+ cache.writeFragment({
177
+ id: cache.identify({ id, __typename: 'OsceStation' }),
178
+ data: {
179
+ status,
180
+ },
181
+ fragment: STATION_CONCEPT_FRAGMENT,
182
+ });
183
+ });
184
+ };
185
+ exports.updateCacheOnStationLearningStatusUpdate = updateCacheOnStationLearningStatusUpdate;
84
186
  exports.UPSERT_USER_VIDEO_STATUS = (0, client_1.gql) `
85
187
  mutation UpsertUserVideoStatus($videoIds: [Int!]!, $status: Int!) {
86
188
  restricted {
@@ -94,3 +196,80 @@ exports.UPSERT_USER_VIDEO_STATUS = (0, client_1.gql) `
94
196
  }
95
197
  }
96
198
  `;
199
+ const VIDEO_STATUS_FRAGMENT = (0, client_1.gql) `
200
+ fragment VideoStatus on Video {
201
+ status
202
+ }
203
+ `;
204
+ const TOPIC_VIDEO_STATUS_STATS_FRAGMENT = (0, client_1.gql) `
205
+ fragment TopicVideoStatusStats on Topic {
206
+ unwatchedVideos
207
+ completedVideos
208
+ revisingVideos
209
+ urgentVideos
210
+ }
211
+ `;
212
+ const getVideoStatsFieldName = (status) => {
213
+ switch (status) {
214
+ case models_1.EUserLearningStatus.URGENT:
215
+ return 'urgentVideos';
216
+ case models_1.EUserLearningStatus.REVISING:
217
+ return 'revisingVideos';
218
+ case models_1.EUserLearningStatus.COMPLETED:
219
+ return 'completedVideos';
220
+ case models_1.EUserLearningStatus.UNREAD:
221
+ default:
222
+ return 'unwatchedVideos';
223
+ }
224
+ };
225
+ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
226
+ getVideoStatsFieldName(prevStatus),
227
+ getVideoStatsFieldName(newStatus),
228
+ ];
229
+ const updateCacheOnVideoLearningStatusUpdate = (prevStatus, topicId) => (cache, result, options) => {
230
+ const { upsertUserVideoStatus } = result?.data?.restricted || {};
231
+ const { variables } = options || {};
232
+ if (!variables || !upsertUserVideoStatus) {
233
+ return;
234
+ }
235
+ const { videoIds, status } = variables;
236
+ videoIds.forEach((id) => {
237
+ cache.writeFragment({
238
+ id: cache.identify({ id, __typename: 'Video' }),
239
+ data: {
240
+ status,
241
+ },
242
+ fragment: VIDEO_STATUS_FRAGMENT,
243
+ });
244
+ });
245
+ if (!topicId) {
246
+ return;
247
+ }
248
+ const prevData = cache.readFragment({
249
+ id: cache.identify({
250
+ id: topicId,
251
+ __typename: 'Topic',
252
+ }),
253
+ fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
254
+ });
255
+ if (prevData) {
256
+ const [prevStatName, newStatName] = getVideoUpdatedFieldNames(status, prevStatus);
257
+ const newData = {
258
+ ...prevData,
259
+ [newStatName]: (prevData[newStatName] || 0) + videoIds.length,
260
+ };
261
+ if (prevStatus !== undefined &&
262
+ prevStatus !== null &&
263
+ prevData[prevStatName]) {
264
+ newData[prevStatName] = (prevData[prevStatName] || 0) - videoIds.length;
265
+ }
266
+ cache.writeFragment({
267
+ id: cache.identify({ id: topicId, __typename: 'Topic' }),
268
+ data: {
269
+ ...newData,
270
+ },
271
+ fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
272
+ });
273
+ }
274
+ };
275
+ exports.updateCacheOnVideoLearningStatusUpdate = updateCacheOnVideoLearningStatusUpdate;
@@ -40,6 +40,7 @@ exports.VIDEO = (0, client_1.gql) `
40
40
  osceStation {
41
41
  id
42
42
  name
43
+ status
43
44
  osceType {
44
45
  id
45
46
  }
@@ -97,6 +97,7 @@ exports.SAMPLE_VIDEO = (0, client_1.gql) `
97
97
  osceStation {
98
98
  id
99
99
  name
100
+ status
100
101
  osceType {
101
102
  id
102
103
  }
@@ -3,6 +3,7 @@ import { EDifficultyType } from './Difficulty';
3
3
  import { IPicture } from './Picture';
4
4
  import { ITopic } from './Topic';
5
5
  import { Id } from './Type';
6
+ import { EUserLearningStatus } from './User';
6
7
  import { IVideo } from './Video';
7
8
  export interface IOsceType {
8
9
  id: Id;
@@ -50,6 +51,7 @@ export interface IOsceStation {
50
51
  videos?: IVideo[];
51
52
  lastOsceMarksheetId?: Id;
52
53
  score?: number;
54
+ status?: EUserLearningStatus;
53
55
  }
54
56
  export interface IOsceStationTopic {
55
57
  id: Id;
@@ -16,6 +16,7 @@ export const OSCE_STATION_FIELDS = gql `
16
16
  id
17
17
  updatedAt
18
18
  name
19
+ status
19
20
  osceType {
20
21
  id
21
22
  name
@@ -47,6 +48,7 @@ export const OSCE_STATION_FIELDS = gql `
47
48
  videos {
48
49
  id
49
50
  title
51
+ status
50
52
  museId
51
53
  thumbnail
52
54
  concepts {
@@ -1,5 +1,7 @@
1
- import { EUserLearningStatus, Id, IUser, IUserConceptStatus, IUserStationStatus, IUserVideoStatus } from '../../../models';
2
- import { graphqlNormalize, RestrictedData } from '../../types';
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { EUserLearningStatus, IUser, IUserConceptStatus, IUserStationStatus, IUserVideoStatus, Id } from '../../../models';
3
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
3
5
  export declare const RESET_PROGRESS: import("@apollo/client").DocumentNode;
4
6
  export interface IResetProgressVar {
5
7
  questions?: boolean;
@@ -45,15 +47,18 @@ export type IUpsertUserConceptStatusVar = {
45
47
  };
46
48
  export type IUpsertUserConceptStatusData = RestrictedData<graphqlNormalize & IUserConceptStatus[], 'upsertUserConceptStatus'>;
47
49
  export declare const UPSERT_USER_CONCEPT_STATUS: import("@apollo/client").DocumentNode;
50
+ export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
48
51
  export type IUpsertUserStationStatusVar = {
49
52
  osceStationIds: Id[];
50
53
  status: EUserLearningStatus;
51
54
  };
52
55
  export type IUpsertUserStationStatusData = RestrictedData<graphqlNormalize & IUserStationStatus[], 'upsertUserStationStatus'>;
53
56
  export declare const UPSERT_USER_STATION_STATUS: import("@apollo/client").DocumentNode;
57
+ export declare const updateCacheOnStationLearningStatusUpdate: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserStationStatusData>, options: ApolloUpdateOptions) => void;
54
58
  export type IUpsertUserVideoStatusVar = {
55
59
  videoIds: Id[];
56
60
  status: EUserLearningStatus;
57
61
  };
58
62
  export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
59
63
  export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
64
+ export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null, topicId?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
@@ -1,4 +1,5 @@
1
1
  import { gql } from '@apollo/client';
2
+ import { EUserLearningStatus, } from '../../../models';
2
3
  export const RESET_PROGRESS = gql `
3
4
  mutation ResetProgress($questions: Boolean, $cards: Boolean) {
4
5
  restricted {
@@ -65,10 +66,87 @@ export const UPSERT_USER_CONCEPT_STATUS = gql `
65
66
  }
66
67
  }
67
68
  `;
69
+ const STATUS_CONCEPT_FRAGMENT = gql `
70
+ fragment ConceptStatus on Concept {
71
+ status
72
+ }
73
+ `;
74
+ const TOPIC_CONCEPT_STATUS_STATS_FRAGMENT = gql `
75
+ fragment TopicConceptStatusStats on Topic {
76
+ unreadConcepts
77
+ completedConcepts
78
+ revisingConcepts
79
+ urgentConcepts
80
+ }
81
+ `;
82
+ const getConceptStatsFieldName = (status) => {
83
+ switch (status) {
84
+ case EUserLearningStatus.URGENT:
85
+ return 'urgentConcepts';
86
+ case EUserLearningStatus.REVISING:
87
+ return 'revisingConcepts';
88
+ case EUserLearningStatus.COMPLETED:
89
+ return 'completedConcepts';
90
+ case EUserLearningStatus.UNREAD:
91
+ default:
92
+ return 'unreadConcepts';
93
+ }
94
+ };
95
+ const getConceptUpdatedFieldNames = (newStatus, prevStatus) => [
96
+ getConceptStatsFieldName(prevStatus),
97
+ getConceptStatsFieldName(newStatus),
98
+ ];
99
+ export const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache, result, options) => {
100
+ const { upsertUserConceptStatus } = result?.data?.restricted || {};
101
+ const { variables } = options || {};
102
+ if (!variables || !upsertUserConceptStatus) {
103
+ return;
104
+ }
105
+ const { conceptIds, status } = variables;
106
+ conceptIds.forEach((id) => {
107
+ cache.writeFragment({
108
+ id: cache.identify({ id, __typename: 'Concept' }),
109
+ data: {
110
+ status,
111
+ },
112
+ fragment: STATUS_CONCEPT_FRAGMENT,
113
+ });
114
+ });
115
+ const prevData = cache.readFragment({
116
+ id: cache.identify({
117
+ id: topicId,
118
+ __typename: 'Topic',
119
+ }),
120
+ fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
121
+ });
122
+ if (prevData) {
123
+ const [prevStatName, newStatName] = getConceptUpdatedFieldNames(status, prevStatus);
124
+ const newData = {
125
+ ...prevData,
126
+ [newStatName]: (prevData[newStatName] || 0) + conceptIds.length,
127
+ };
128
+ if (prevStatus !== undefined &&
129
+ prevStatus !== null &&
130
+ prevData[prevStatName]) {
131
+ newData[prevStatName] =
132
+ (prevData[prevStatName] || 0) - conceptIds.length;
133
+ }
134
+ cache.writeFragment({
135
+ id: cache.identify({ id: topicId, __typename: 'Topic' }),
136
+ data: {
137
+ ...newData,
138
+ },
139
+ fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
140
+ });
141
+ }
142
+ };
68
143
  export const UPSERT_USER_STATION_STATUS = gql `
69
144
  mutation UpsertUserStationStatus($osceStationIds: [Int!]!, $status: Int!) {
70
145
  restricted {
71
- upsertUserStationStatus(osceStationIds: $osceStationIds, status: $status) {
146
+ upsertUserStationStatus(
147
+ osceStationIds: $osceStationIds
148
+ status: $status
149
+ ) {
72
150
  id
73
151
  status
74
152
  osceStationId
@@ -78,6 +156,28 @@ export const UPSERT_USER_STATION_STATUS = gql `
78
156
  }
79
157
  }
80
158
  `;
159
+ const STATION_CONCEPT_FRAGMENT = gql `
160
+ fragment StationStatus on OsceStation {
161
+ status
162
+ }
163
+ `;
164
+ export const updateCacheOnStationLearningStatusUpdate = (cache, result, options) => {
165
+ const { upsertUserStationStatus } = result?.data?.restricted || {};
166
+ const { variables } = options || {};
167
+ if (!variables || !upsertUserStationStatus) {
168
+ return;
169
+ }
170
+ const { osceStationIds, status } = variables;
171
+ osceStationIds.forEach((id) => {
172
+ cache.writeFragment({
173
+ id: cache.identify({ id, __typename: 'OsceStation' }),
174
+ data: {
175
+ status,
176
+ },
177
+ fragment: STATION_CONCEPT_FRAGMENT,
178
+ });
179
+ });
180
+ };
81
181
  export const UPSERT_USER_VIDEO_STATUS = gql `
82
182
  mutation UpsertUserVideoStatus($videoIds: [Int!]!, $status: Int!) {
83
183
  restricted {
@@ -91,3 +191,79 @@ export const UPSERT_USER_VIDEO_STATUS = gql `
91
191
  }
92
192
  }
93
193
  `;
194
+ const VIDEO_STATUS_FRAGMENT = gql `
195
+ fragment VideoStatus on Video {
196
+ status
197
+ }
198
+ `;
199
+ const TOPIC_VIDEO_STATUS_STATS_FRAGMENT = gql `
200
+ fragment TopicVideoStatusStats on Topic {
201
+ unwatchedVideos
202
+ completedVideos
203
+ revisingVideos
204
+ urgentVideos
205
+ }
206
+ `;
207
+ const getVideoStatsFieldName = (status) => {
208
+ switch (status) {
209
+ case EUserLearningStatus.URGENT:
210
+ return 'urgentVideos';
211
+ case EUserLearningStatus.REVISING:
212
+ return 'revisingVideos';
213
+ case EUserLearningStatus.COMPLETED:
214
+ return 'completedVideos';
215
+ case EUserLearningStatus.UNREAD:
216
+ default:
217
+ return 'unwatchedVideos';
218
+ }
219
+ };
220
+ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
221
+ getVideoStatsFieldName(prevStatus),
222
+ getVideoStatsFieldName(newStatus),
223
+ ];
224
+ export const updateCacheOnVideoLearningStatusUpdate = (prevStatus, topicId) => (cache, result, options) => {
225
+ const { upsertUserVideoStatus } = result?.data?.restricted || {};
226
+ const { variables } = options || {};
227
+ if (!variables || !upsertUserVideoStatus) {
228
+ return;
229
+ }
230
+ const { videoIds, status } = variables;
231
+ videoIds.forEach((id) => {
232
+ cache.writeFragment({
233
+ id: cache.identify({ id, __typename: 'Video' }),
234
+ data: {
235
+ status,
236
+ },
237
+ fragment: VIDEO_STATUS_FRAGMENT,
238
+ });
239
+ });
240
+ if (!topicId) {
241
+ return;
242
+ }
243
+ const prevData = cache.readFragment({
244
+ id: cache.identify({
245
+ id: topicId,
246
+ __typename: 'Topic',
247
+ }),
248
+ fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
249
+ });
250
+ if (prevData) {
251
+ const [prevStatName, newStatName] = getVideoUpdatedFieldNames(status, prevStatus);
252
+ const newData = {
253
+ ...prevData,
254
+ [newStatName]: (prevData[newStatName] || 0) + videoIds.length,
255
+ };
256
+ if (prevStatus !== undefined &&
257
+ prevStatus !== null &&
258
+ prevData[prevStatName]) {
259
+ newData[prevStatName] = (prevData[prevStatName] || 0) - videoIds.length;
260
+ }
261
+ cache.writeFragment({
262
+ id: cache.identify({ id: topicId, __typename: 'Topic' }),
263
+ data: {
264
+ ...newData,
265
+ },
266
+ fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
267
+ });
268
+ }
269
+ };
@@ -37,6 +37,7 @@ export const VIDEO = gql `
37
37
  osceStation {
38
38
  id
39
39
  name
40
+ status
40
41
  osceType {
41
42
  id
42
43
  }
@@ -94,6 +94,7 @@ export const SAMPLE_VIDEO = gql `
94
94
  osceStation {
95
95
  id
96
96
  name
97
+ status
97
98
  osceType {
98
99
  id
99
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.5.14",
3
+ "version": "2.5.16",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",