@quesmed/types-rn 2.5.22 → 2.5.25
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
|
@@ -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;
|