@quesmed/types-rn 2.6.200 → 2.6.201

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.200",
3
+ "version": "2.6.201",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -70,7 +70,7 @@ export type IUpsertUserConceptStatusVar = {
70
70
  };
71
71
  export type IUpsertUserConceptStatusData = RestrictedData<graphqlNormalize & IUserConceptStatus[], 'upsertUserConceptStatus'>;
72
72
  export declare const UPSERT_USER_CONCEPT_STATUS: import("@apollo/client").DocumentNode;
73
- export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
73
+ export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null, entitlement?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
74
74
  export declare const optimisticConceptLearningStatus: (id: number, conceptIds: number[], userId: number, status: EUserLearningStatus) => IUpsertUserConceptStatusData;
75
75
  export type IUpsertUserStationStatusVar = {
76
76
  osceStationIds: Id[];
@@ -86,5 +86,5 @@ export type IUpsertUserVideoStatusVar = {
86
86
  };
87
87
  export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
88
88
  export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
89
- export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
89
+ export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null, entitlement?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
90
90
  export declare const optimisticVideoLearningStatus: (id: number, videoIds: number[], userId: number, status: EUserLearningStatus) => IUpsertUserVideoStatusData;
@@ -202,7 +202,7 @@ const getConceptUpdatedFieldNames = (newStatus, prevStatus) => [
202
202
  getConceptStatsFieldName(prevStatus),
203
203
  getConceptStatsFieldName(newStatus),
204
204
  ];
205
- const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache, result, options) => {
205
+ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus, entitlement) => (cache, result, options) => {
206
206
  const { upsertUserConceptStatus } = result?.data?.restricted || {};
207
207
  const { variables } = options || {};
208
208
  if (!variables || !upsertUserConceptStatus) {
@@ -212,17 +212,24 @@ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache
212
212
  conceptIds.forEach((id) => {
213
213
  cache.writeFragment({
214
214
  id: cache.identify({ id, __typename: 'Concept' }),
215
- data: {
216
- status,
217
- },
215
+ data: { status },
218
216
  fragment: STATUS_CONCEPT_FRAGMENT,
219
217
  });
220
218
  });
221
- const prevData = cache.readFragment({
222
- id: cache.identify({
223
- id: topicId,
224
- __typename: 'Topic',
219
+ const topicFragmentId = cache.identify({
220
+ id: topicId.toString(),
221
+ ...(entitlement && {
222
+ entitlement: {
223
+ __ref: cache.identify({
224
+ id: entitlement,
225
+ __typename: 'Entitlement',
226
+ }),
227
+ },
225
228
  }),
229
+ __typename: 'Topic',
230
+ });
231
+ const prevData = cache.readFragment({
232
+ id: topicFragmentId,
226
233
  fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
227
234
  });
228
235
  if (prevData) {
@@ -238,7 +245,7 @@ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache
238
245
  (prevData[prevStatName] || 0) - conceptIds.length;
239
246
  }
240
247
  cache.writeFragment({
241
- id: cache.identify({ id: topicId, __typename: 'Topic' }),
248
+ id: topicFragmentId,
242
249
  data: {
243
250
  ...newData,
244
251
  },
@@ -376,7 +383,7 @@ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
376
383
  getVideoStatsFieldName(prevStatus),
377
384
  getVideoStatsFieldName(newStatus),
378
385
  ];
379
- const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, options) => {
386
+ const updateCacheOnVideoLearningStatusUpdate = (prevStatus, entitlement) => (cache, result, options) => {
380
387
  const { upsertUserVideoStatus } = result?.data?.restricted || {};
381
388
  const { variables } = options || {};
382
389
  if (!variables || !upsertUserVideoStatus) {
@@ -386,9 +393,7 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, o
386
393
  videoIds.forEach((id) => {
387
394
  cache.writeFragment({
388
395
  id: cache.identify({ id, __typename: 'Video' }),
389
- data: {
390
- status,
391
- },
396
+ data: { status },
392
397
  fragment: VIDEO_STATUS_FRAGMENT,
393
398
  });
394
399
  });
@@ -405,11 +410,20 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, o
405
410
  return;
406
411
  }
407
412
  [...topicIds].forEach((topicId) => {
408
- const prevData = cache.readFragment({
409
- id: cache.identify({
410
- id: topicId,
411
- __typename: 'Topic',
413
+ const topicFragmentId = cache.identify({
414
+ id: topicId.toString(),
415
+ ...(entitlement && {
416
+ entitlement: {
417
+ __ref: cache.identify({
418
+ id: entitlement,
419
+ __typename: 'Entitlement',
420
+ }),
421
+ },
412
422
  }),
423
+ __typename: 'Topic',
424
+ });
425
+ const prevData = cache.readFragment({
426
+ id: topicFragmentId,
413
427
  fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
414
428
  });
415
429
  if (prevData) {
@@ -425,7 +439,7 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, o
425
439
  (prevData[prevStatName] || 0) - videoIds.length;
426
440
  }
427
441
  cache.writeFragment({
428
- id: cache.identify({ id: topicId, __typename: 'Topic' }),
442
+ id: topicFragmentId,
429
443
  data: {
430
444
  ...newData,
431
445
  },