@quesmed/types 2.5.22 → 2.5.26
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.
|
@@ -61,4 +61,4 @@ export type IUpsertUserVideoStatusVar = {
|
|
|
61
61
|
};
|
|
62
62
|
export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
|
|
63
63
|
export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
|
|
64
|
-
export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null
|
|
64
|
+
export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
|
|
@@ -232,7 +232,7 @@ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
|
|
|
232
232
|
getVideoStatsFieldName(prevStatus),
|
|
233
233
|
getVideoStatsFieldName(newStatus),
|
|
234
234
|
];
|
|
235
|
-
const updateCacheOnVideoLearningStatusUpdate = (prevStatus
|
|
235
|
+
const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, options) => {
|
|
236
236
|
const { upsertUserVideoStatus } = result?.data?.restricted || {};
|
|
237
237
|
const { variables } = options || {};
|
|
238
238
|
if (!variables || !upsertUserVideoStatus) {
|
|
@@ -248,34 +248,46 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus, topicId) => (cache,
|
|
|
248
248
|
fragment: VIDEO_STATUS_FRAGMENT,
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
|
-
|
|
251
|
+
const topicIds = new Set();
|
|
252
|
+
upsertUserVideoStatus.forEach(({ video }) => {
|
|
253
|
+
const { concepts } = video;
|
|
254
|
+
if (concepts) {
|
|
255
|
+
concepts.forEach(({ topicId }) => {
|
|
256
|
+
topicIds.add(Number(topicId));
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
if (!topicIds.size) {
|
|
252
261
|
return;
|
|
253
262
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
id:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
261
|
-
if (prevData) {
|
|
262
|
-
const [prevStatName, newStatName] = getVideoUpdatedFieldNames(status, prevStatus);
|
|
263
|
-
const newData = {
|
|
264
|
-
...prevData,
|
|
265
|
-
[newStatName]: (prevData[newStatName] || 0) + videoIds.length,
|
|
266
|
-
};
|
|
267
|
-
if (prevStatus !== undefined &&
|
|
268
|
-
prevStatus !== null &&
|
|
269
|
-
prevData[prevStatName]) {
|
|
270
|
-
newData[prevStatName] = (prevData[prevStatName] || 0) - videoIds.length;
|
|
271
|
-
}
|
|
272
|
-
cache.writeFragment({
|
|
273
|
-
id: cache.identify({ id: topicId, __typename: 'Topic' }),
|
|
274
|
-
data: {
|
|
275
|
-
...newData,
|
|
276
|
-
},
|
|
263
|
+
[...topicIds].forEach((topicId) => {
|
|
264
|
+
const prevData = cache.readFragment({
|
|
265
|
+
id: cache.identify({
|
|
266
|
+
id: topicId,
|
|
267
|
+
__typename: 'Topic',
|
|
268
|
+
}),
|
|
277
269
|
fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
|
|
278
270
|
});
|
|
279
|
-
|
|
271
|
+
if (prevData) {
|
|
272
|
+
const [prevStatName, newStatName] = getVideoUpdatedFieldNames(status, prevStatus);
|
|
273
|
+
const newData = {
|
|
274
|
+
...prevData,
|
|
275
|
+
[newStatName]: (prevData[newStatName] || 0) + videoIds.length,
|
|
276
|
+
};
|
|
277
|
+
if (prevStatus !== undefined &&
|
|
278
|
+
prevStatus !== null &&
|
|
279
|
+
prevData[prevStatName]) {
|
|
280
|
+
newData[prevStatName] =
|
|
281
|
+
(prevData[prevStatName] || 0) - videoIds.length;
|
|
282
|
+
}
|
|
283
|
+
cache.writeFragment({
|
|
284
|
+
id: cache.identify({ id: topicId, __typename: 'Topic' }),
|
|
285
|
+
data: {
|
|
286
|
+
...newData,
|
|
287
|
+
},
|
|
288
|
+
fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
280
292
|
};
|
|
281
293
|
exports.updateCacheOnVideoLearningStatusUpdate = updateCacheOnVideoLearningStatusUpdate;
|
|
@@ -61,4 +61,4 @@ export type IUpsertUserVideoStatusVar = {
|
|
|
61
61
|
};
|
|
62
62
|
export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
|
|
63
63
|
export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
|
|
64
|
-
export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null
|
|
64
|
+
export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
|
|
@@ -227,7 +227,7 @@ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
|
|
|
227
227
|
getVideoStatsFieldName(prevStatus),
|
|
228
228
|
getVideoStatsFieldName(newStatus),
|
|
229
229
|
];
|
|
230
|
-
export const updateCacheOnVideoLearningStatusUpdate = (prevStatus
|
|
230
|
+
export const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, options) => {
|
|
231
231
|
const { upsertUserVideoStatus } = result?.data?.restricted || {};
|
|
232
232
|
const { variables } = options || {};
|
|
233
233
|
if (!variables || !upsertUserVideoStatus) {
|
|
@@ -243,33 +243,45 @@ export const updateCacheOnVideoLearningStatusUpdate = (prevStatus, topicId) => (
|
|
|
243
243
|
fragment: VIDEO_STATUS_FRAGMENT,
|
|
244
244
|
});
|
|
245
245
|
});
|
|
246
|
-
|
|
246
|
+
const topicIds = new Set();
|
|
247
|
+
upsertUserVideoStatus.forEach(({ video }) => {
|
|
248
|
+
const { concepts } = video;
|
|
249
|
+
if (concepts) {
|
|
250
|
+
concepts.forEach(({ topicId }) => {
|
|
251
|
+
topicIds.add(Number(topicId));
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
if (!topicIds.size) {
|
|
247
256
|
return;
|
|
248
257
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
id:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
if (prevData) {
|
|
257
|
-
const [prevStatName, newStatName] = getVideoUpdatedFieldNames(status, prevStatus);
|
|
258
|
-
const newData = {
|
|
259
|
-
...prevData,
|
|
260
|
-
[newStatName]: (prevData[newStatName] || 0) + videoIds.length,
|
|
261
|
-
};
|
|
262
|
-
if (prevStatus !== undefined &&
|
|
263
|
-
prevStatus !== null &&
|
|
264
|
-
prevData[prevStatName]) {
|
|
265
|
-
newData[prevStatName] = (prevData[prevStatName] || 0) - videoIds.length;
|
|
266
|
-
}
|
|
267
|
-
cache.writeFragment({
|
|
268
|
-
id: cache.identify({ id: topicId, __typename: 'Topic' }),
|
|
269
|
-
data: {
|
|
270
|
-
...newData,
|
|
271
|
-
},
|
|
258
|
+
[...topicIds].forEach((topicId) => {
|
|
259
|
+
const prevData = cache.readFragment({
|
|
260
|
+
id: cache.identify({
|
|
261
|
+
id: topicId,
|
|
262
|
+
__typename: 'Topic',
|
|
263
|
+
}),
|
|
272
264
|
fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
|
|
273
265
|
});
|
|
274
|
-
|
|
266
|
+
if (prevData) {
|
|
267
|
+
const [prevStatName, newStatName] = getVideoUpdatedFieldNames(status, prevStatus);
|
|
268
|
+
const newData = {
|
|
269
|
+
...prevData,
|
|
270
|
+
[newStatName]: (prevData[newStatName] || 0) + videoIds.length,
|
|
271
|
+
};
|
|
272
|
+
if (prevStatus !== undefined &&
|
|
273
|
+
prevStatus !== null &&
|
|
274
|
+
prevData[prevStatName]) {
|
|
275
|
+
newData[prevStatName] =
|
|
276
|
+
(prevData[prevStatName] || 0) - videoIds.length;
|
|
277
|
+
}
|
|
278
|
+
cache.writeFragment({
|
|
279
|
+
id: cache.identify({ id: topicId, __typename: 'Topic' }),
|
|
280
|
+
data: {
|
|
281
|
+
...newData,
|
|
282
|
+
},
|
|
283
|
+
fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
});
|
|
275
287
|
};
|