tsdf 14.2.0 → 15.0.0
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/dist/main.cjs +52 -84
- package/dist/main.d.cts +6 -7
- package/dist/main.d.ts +6 -7
- package/dist/main.js +52 -84
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1240,7 +1240,6 @@ function newTSDFListQueryStore({
|
|
|
1240
1240
|
disableInitialDataInvalidation,
|
|
1241
1241
|
mediumPriorityThrottleMs,
|
|
1242
1242
|
dynamicRealtimeThrottleMs,
|
|
1243
|
-
syncMutationsAndInvalidations,
|
|
1244
1243
|
optimisticListUpdates,
|
|
1245
1244
|
onInvalidateItem,
|
|
1246
1245
|
onInvalidateQuery
|
|
@@ -1517,9 +1516,46 @@ function newTSDFListQueryStore({
|
|
|
1517
1516
|
}
|
|
1518
1517
|
}
|
|
1519
1518
|
const storeEvents = (0, import_evtmitter4.evtmitter)();
|
|
1519
|
+
const itemInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
1520
|
+
function invalidateItem(itemId, priority = "highPriority") {
|
|
1521
|
+
if (!fetchItemOrquestrator) {
|
|
1522
|
+
throw new Error(noFetchFnError);
|
|
1523
|
+
}
|
|
1524
|
+
const itemsKey = getItemsKeyArray(itemId);
|
|
1525
|
+
for (const { itemKey, payload } of itemsKey) {
|
|
1526
|
+
const item = store.state.itemQueries[itemKey];
|
|
1527
|
+
if (!item)
|
|
1528
|
+
continue;
|
|
1529
|
+
const currentInvalidationPriority = item.refetchOnMount ? fetchTypePriority[item.refetchOnMount] : -1;
|
|
1530
|
+
const newInvalidationPriority = fetchTypePriority[priority];
|
|
1531
|
+
if (currentInvalidationPriority >= newInvalidationPriority)
|
|
1532
|
+
continue;
|
|
1533
|
+
store.produceState(
|
|
1534
|
+
(draft) => {
|
|
1535
|
+
const query = draft.itemQueries[itemKey];
|
|
1536
|
+
if (!query)
|
|
1537
|
+
return;
|
|
1538
|
+
query.refetchOnMount = priority;
|
|
1539
|
+
},
|
|
1540
|
+
{ action: { type: "invalidate-item", queryKey: itemKey } }
|
|
1541
|
+
);
|
|
1542
|
+
itemInvalidationWasTriggered.delete(itemKey);
|
|
1543
|
+
storeEvents.emit("invalidateItem", { priority, itemKey });
|
|
1544
|
+
if (onInvalidateItem) {
|
|
1545
|
+
const itemState = store.state.items[itemKey];
|
|
1546
|
+
if (itemState) {
|
|
1547
|
+
onInvalidateItem({ priority, itemState, payload });
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1520
1552
|
const queryInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
1521
|
-
function
|
|
1522
|
-
|
|
1553
|
+
function invalidateQueryAndItems({
|
|
1554
|
+
itemPayload,
|
|
1555
|
+
queryPayload,
|
|
1556
|
+
type: priority = "highPriority"
|
|
1557
|
+
}) {
|
|
1558
|
+
const queriesKey = queryPayload ? getQueriesKeyArray(queryPayload) : [];
|
|
1523
1559
|
for (const { key, payload } of queriesKey) {
|
|
1524
1560
|
const queryState = store.state.queries[key];
|
|
1525
1561
|
if (!queryState)
|
|
@@ -1541,27 +1577,8 @@ function newTSDFListQueryStore({
|
|
|
1541
1577
|
storeEvents.emit("invalidateQuery", { priority, queryKey: key });
|
|
1542
1578
|
onInvalidateQuery?.(payload, priority);
|
|
1543
1579
|
}
|
|
1544
|
-
if (
|
|
1545
|
-
invalidateItem(
|
|
1546
|
-
(itemPayload) => queriesKey.some(({ payload }) => {
|
|
1547
|
-
return syncMutationsAndInvalidations.syncItemAndQuery(
|
|
1548
|
-
itemPayload,
|
|
1549
|
-
payload
|
|
1550
|
-
);
|
|
1551
|
-
}),
|
|
1552
|
-
priority,
|
|
1553
|
-
true
|
|
1554
|
-
);
|
|
1555
|
-
invalidateQuery(
|
|
1556
|
-
(queryToInvalidatePayload, _, queryToInvalidateKey) => queriesKey.some((alreadyInvalidatedQueryPayload) => {
|
|
1557
|
-
return queryToInvalidateKey !== alreadyInvalidatedQueryPayload.key && syncMutationsAndInvalidations.syncQueries(
|
|
1558
|
-
alreadyInvalidatedQueryPayload.payload,
|
|
1559
|
-
queryToInvalidatePayload
|
|
1560
|
-
);
|
|
1561
|
-
}),
|
|
1562
|
-
priority,
|
|
1563
|
-
true
|
|
1564
|
-
);
|
|
1580
|
+
if (itemPayload) {
|
|
1581
|
+
invalidateItem(itemPayload, priority);
|
|
1565
1582
|
}
|
|
1566
1583
|
}
|
|
1567
1584
|
function defaultItemSelector(data) {
|
|
@@ -1886,70 +1903,19 @@ function newTSDFListQueryStore({
|
|
|
1886
1903
|
}
|
|
1887
1904
|
return [{ payload: itemsPayload, itemKey: getItemKey(itemsPayload) }];
|
|
1888
1905
|
}
|
|
1889
|
-
const itemInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
1890
|
-
function invalidateItem(itemId, priority = "highPriority", ignoreInvalidationSync = false) {
|
|
1891
|
-
if (!fetchItemOrquestrator) {
|
|
1892
|
-
throw new Error(noFetchFnError);
|
|
1893
|
-
}
|
|
1894
|
-
const itemsKey = getItemsKeyArray(itemId);
|
|
1895
|
-
for (const { itemKey, payload } of itemsKey) {
|
|
1896
|
-
const item = store.state.itemQueries[itemKey];
|
|
1897
|
-
if (!item)
|
|
1898
|
-
continue;
|
|
1899
|
-
const currentInvalidationPriority = item.refetchOnMount ? fetchTypePriority[item.refetchOnMount] : -1;
|
|
1900
|
-
const newInvalidationPriority = fetchTypePriority[priority];
|
|
1901
|
-
if (currentInvalidationPriority >= newInvalidationPriority)
|
|
1902
|
-
continue;
|
|
1903
|
-
store.produceState(
|
|
1904
|
-
(draft) => {
|
|
1905
|
-
const query = draft.itemQueries[itemKey];
|
|
1906
|
-
if (!query)
|
|
1907
|
-
return;
|
|
1908
|
-
query.refetchOnMount = priority;
|
|
1909
|
-
},
|
|
1910
|
-
{ action: { type: "invalidate-item", queryKey: itemKey } }
|
|
1911
|
-
);
|
|
1912
|
-
itemInvalidationWasTriggered.delete(itemKey);
|
|
1913
|
-
storeEvents.emit("invalidateItem", { priority, itemKey });
|
|
1914
|
-
if (onInvalidateItem) {
|
|
1915
|
-
const itemState = store.state.items[itemKey];
|
|
1916
|
-
if (itemState) {
|
|
1917
|
-
onInvalidateItem({
|
|
1918
|
-
priority,
|
|
1919
|
-
itemState,
|
|
1920
|
-
payload
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
if (syncMutationsAndInvalidations && !ignoreInvalidationSync) {
|
|
1926
|
-
invalidateQuery(
|
|
1927
|
-
(query) => itemsKey.some(
|
|
1928
|
-
({ payload }) => syncMutationsAndInvalidations.syncItemAndQuery(payload, query)
|
|
1929
|
-
),
|
|
1930
|
-
priority,
|
|
1931
|
-
true
|
|
1932
|
-
);
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
1906
|
function startItemMutation(itemId) {
|
|
1936
1907
|
const itemsKey = getItemsKeyArray(itemId);
|
|
1937
1908
|
const endMutations = [];
|
|
1938
|
-
for (const { itemKey
|
|
1909
|
+
for (const { itemKey } of itemsKey) {
|
|
1939
1910
|
endMutations.push(
|
|
1940
1911
|
fetchItemOrquestrator?.get(itemKey).startMutation() || (() => {
|
|
1941
1912
|
})
|
|
1942
1913
|
);
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
)) {
|
|
1949
|
-
endMutations.push(
|
|
1950
|
-
fetchQueryOrquestrator.get(queryKey).startMutation()
|
|
1951
|
-
);
|
|
1952
|
-
}
|
|
1914
|
+
for (const [queryKey, query] of Object.entries(store.state.queries)) {
|
|
1915
|
+
if (query.items.includes(itemKey)) {
|
|
1916
|
+
endMutations.push(
|
|
1917
|
+
fetchQueryOrquestrator.get(queryKey).startMutation()
|
|
1918
|
+
);
|
|
1953
1919
|
}
|
|
1954
1920
|
}
|
|
1955
1921
|
}
|
|
@@ -2307,7 +2273,10 @@ function newTSDFListQueryStore({
|
|
|
2307
2273
|
}
|
|
2308
2274
|
});
|
|
2309
2275
|
if (queriesToInvalidate.length)
|
|
2310
|
-
|
|
2276
|
+
invalidateQueryAndItems({
|
|
2277
|
+
queryPayload: queriesToInvalidate,
|
|
2278
|
+
itemPayload: false
|
|
2279
|
+
});
|
|
2311
2280
|
}
|
|
2312
2281
|
function addItemToState(itemPayload, data, {
|
|
2313
2282
|
addItemToQueries
|
|
@@ -2390,8 +2359,7 @@ function newTSDFListQueryStore({
|
|
|
2390
2359
|
deleteItemState,
|
|
2391
2360
|
getItemState,
|
|
2392
2361
|
loadMore,
|
|
2393
|
-
|
|
2394
|
-
invalidateItem,
|
|
2362
|
+
invalidateQueryAndItems,
|
|
2395
2363
|
scheduleItemFetch,
|
|
2396
2364
|
awaitItemFetch,
|
|
2397
2365
|
awaitListQueryFetch,
|
package/dist/main.d.cts
CHANGED
|
@@ -237,7 +237,7 @@ type ListQueryUseMultipleListQueriesQuery<QueryPayload extends ValidPayload, Que
|
|
|
237
237
|
isOffScreen?: boolean;
|
|
238
238
|
loadSize?: number;
|
|
239
239
|
};
|
|
240
|
-
declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs,
|
|
240
|
+
declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, optimisticListUpdates, onInvalidateItem, onInvalidateQuery, }: {
|
|
241
241
|
debugName?: string;
|
|
242
242
|
fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
|
|
243
243
|
fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
|
|
@@ -245,10 +245,6 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
245
245
|
defaultQuerySize?: number;
|
|
246
246
|
getInitialData?: () => ListQueryStoreInitialData<ItemState, QueryPayload, ItemPayload> | undefined;
|
|
247
247
|
disableInitialDataInvalidation?: boolean;
|
|
248
|
-
syncMutationsAndInvalidations?: {
|
|
249
|
-
syncQueries: (query1: QueryPayload, query2: QueryPayload) => boolean;
|
|
250
|
-
syncItemAndQuery: (itemPayload: ItemPayload, query: QueryPayload) => boolean;
|
|
251
|
-
};
|
|
252
248
|
disableRefetchOnMount?: boolean;
|
|
253
249
|
lowPriorityThrottleMs?: number;
|
|
254
250
|
mediumPriorityThrottleMs?: number;
|
|
@@ -285,8 +281,11 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
285
281
|
(itemPayload: ItemPayload): ItemState | null | undefined;
|
|
286
282
|
};
|
|
287
283
|
loadMore: (params: QueryPayload, size?: number) => ScheduleFetchResults;
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
invalidateQueryAndItems: ({ itemPayload, queryPayload, type: priority, }: {
|
|
285
|
+
itemPayload: false | ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[];
|
|
286
|
+
queryPayload: false | QueryPayload | QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean);
|
|
287
|
+
type?: FetchType | undefined;
|
|
288
|
+
}) => void;
|
|
290
289
|
scheduleItemFetch: {
|
|
291
290
|
(fetchType: FetchType, itemPayload: ItemPayload): ScheduleFetchResults;
|
|
292
291
|
(fetchType: FetchType, itemPayload: ItemPayload[]): ScheduleFetchResults[];
|
package/dist/main.d.ts
CHANGED
|
@@ -237,7 +237,7 @@ type ListQueryUseMultipleListQueriesQuery<QueryPayload extends ValidPayload, Que
|
|
|
237
237
|
isOffScreen?: boolean;
|
|
238
238
|
loadSize?: number;
|
|
239
239
|
};
|
|
240
|
-
declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs,
|
|
240
|
+
declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, optimisticListUpdates, onInvalidateItem, onInvalidateQuery, }: {
|
|
241
241
|
debugName?: string;
|
|
242
242
|
fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
|
|
243
243
|
fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
|
|
@@ -245,10 +245,6 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
245
245
|
defaultQuerySize?: number;
|
|
246
246
|
getInitialData?: () => ListQueryStoreInitialData<ItemState, QueryPayload, ItemPayload> | undefined;
|
|
247
247
|
disableInitialDataInvalidation?: boolean;
|
|
248
|
-
syncMutationsAndInvalidations?: {
|
|
249
|
-
syncQueries: (query1: QueryPayload, query2: QueryPayload) => boolean;
|
|
250
|
-
syncItemAndQuery: (itemPayload: ItemPayload, query: QueryPayload) => boolean;
|
|
251
|
-
};
|
|
252
248
|
disableRefetchOnMount?: boolean;
|
|
253
249
|
lowPriorityThrottleMs?: number;
|
|
254
250
|
mediumPriorityThrottleMs?: number;
|
|
@@ -285,8 +281,11 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
285
281
|
(itemPayload: ItemPayload): ItemState | null | undefined;
|
|
286
282
|
};
|
|
287
283
|
loadMore: (params: QueryPayload, size?: number) => ScheduleFetchResults;
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
invalidateQueryAndItems: ({ itemPayload, queryPayload, type: priority, }: {
|
|
285
|
+
itemPayload: false | ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[];
|
|
286
|
+
queryPayload: false | QueryPayload | QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean);
|
|
287
|
+
type?: FetchType | undefined;
|
|
288
|
+
}) => void;
|
|
290
289
|
scheduleItemFetch: {
|
|
291
290
|
(fetchType: FetchType, itemPayload: ItemPayload): ScheduleFetchResults;
|
|
292
291
|
(fetchType: FetchType, itemPayload: ItemPayload[]): ScheduleFetchResults[];
|
package/dist/main.js
CHANGED
|
@@ -1210,7 +1210,6 @@ function newTSDFListQueryStore({
|
|
|
1210
1210
|
disableInitialDataInvalidation,
|
|
1211
1211
|
mediumPriorityThrottleMs,
|
|
1212
1212
|
dynamicRealtimeThrottleMs,
|
|
1213
|
-
syncMutationsAndInvalidations,
|
|
1214
1213
|
optimisticListUpdates,
|
|
1215
1214
|
onInvalidateItem,
|
|
1216
1215
|
onInvalidateQuery
|
|
@@ -1487,9 +1486,46 @@ function newTSDFListQueryStore({
|
|
|
1487
1486
|
}
|
|
1488
1487
|
}
|
|
1489
1488
|
const storeEvents = evtmitter4();
|
|
1489
|
+
const itemInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
1490
|
+
function invalidateItem(itemId, priority = "highPriority") {
|
|
1491
|
+
if (!fetchItemOrquestrator) {
|
|
1492
|
+
throw new Error(noFetchFnError);
|
|
1493
|
+
}
|
|
1494
|
+
const itemsKey = getItemsKeyArray(itemId);
|
|
1495
|
+
for (const { itemKey, payload } of itemsKey) {
|
|
1496
|
+
const item = store.state.itemQueries[itemKey];
|
|
1497
|
+
if (!item)
|
|
1498
|
+
continue;
|
|
1499
|
+
const currentInvalidationPriority = item.refetchOnMount ? fetchTypePriority[item.refetchOnMount] : -1;
|
|
1500
|
+
const newInvalidationPriority = fetchTypePriority[priority];
|
|
1501
|
+
if (currentInvalidationPriority >= newInvalidationPriority)
|
|
1502
|
+
continue;
|
|
1503
|
+
store.produceState(
|
|
1504
|
+
(draft) => {
|
|
1505
|
+
const query = draft.itemQueries[itemKey];
|
|
1506
|
+
if (!query)
|
|
1507
|
+
return;
|
|
1508
|
+
query.refetchOnMount = priority;
|
|
1509
|
+
},
|
|
1510
|
+
{ action: { type: "invalidate-item", queryKey: itemKey } }
|
|
1511
|
+
);
|
|
1512
|
+
itemInvalidationWasTriggered.delete(itemKey);
|
|
1513
|
+
storeEvents.emit("invalidateItem", { priority, itemKey });
|
|
1514
|
+
if (onInvalidateItem) {
|
|
1515
|
+
const itemState = store.state.items[itemKey];
|
|
1516
|
+
if (itemState) {
|
|
1517
|
+
onInvalidateItem({ priority, itemState, payload });
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1490
1522
|
const queryInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
1491
|
-
function
|
|
1492
|
-
|
|
1523
|
+
function invalidateQueryAndItems({
|
|
1524
|
+
itemPayload,
|
|
1525
|
+
queryPayload,
|
|
1526
|
+
type: priority = "highPriority"
|
|
1527
|
+
}) {
|
|
1528
|
+
const queriesKey = queryPayload ? getQueriesKeyArray(queryPayload) : [];
|
|
1493
1529
|
for (const { key, payload } of queriesKey) {
|
|
1494
1530
|
const queryState = store.state.queries[key];
|
|
1495
1531
|
if (!queryState)
|
|
@@ -1511,27 +1547,8 @@ function newTSDFListQueryStore({
|
|
|
1511
1547
|
storeEvents.emit("invalidateQuery", { priority, queryKey: key });
|
|
1512
1548
|
onInvalidateQuery?.(payload, priority);
|
|
1513
1549
|
}
|
|
1514
|
-
if (
|
|
1515
|
-
invalidateItem(
|
|
1516
|
-
(itemPayload) => queriesKey.some(({ payload }) => {
|
|
1517
|
-
return syncMutationsAndInvalidations.syncItemAndQuery(
|
|
1518
|
-
itemPayload,
|
|
1519
|
-
payload
|
|
1520
|
-
);
|
|
1521
|
-
}),
|
|
1522
|
-
priority,
|
|
1523
|
-
true
|
|
1524
|
-
);
|
|
1525
|
-
invalidateQuery(
|
|
1526
|
-
(queryToInvalidatePayload, _, queryToInvalidateKey) => queriesKey.some((alreadyInvalidatedQueryPayload) => {
|
|
1527
|
-
return queryToInvalidateKey !== alreadyInvalidatedQueryPayload.key && syncMutationsAndInvalidations.syncQueries(
|
|
1528
|
-
alreadyInvalidatedQueryPayload.payload,
|
|
1529
|
-
queryToInvalidatePayload
|
|
1530
|
-
);
|
|
1531
|
-
}),
|
|
1532
|
-
priority,
|
|
1533
|
-
true
|
|
1534
|
-
);
|
|
1550
|
+
if (itemPayload) {
|
|
1551
|
+
invalidateItem(itemPayload, priority);
|
|
1535
1552
|
}
|
|
1536
1553
|
}
|
|
1537
1554
|
function defaultItemSelector(data) {
|
|
@@ -1856,70 +1873,19 @@ function newTSDFListQueryStore({
|
|
|
1856
1873
|
}
|
|
1857
1874
|
return [{ payload: itemsPayload, itemKey: getItemKey(itemsPayload) }];
|
|
1858
1875
|
}
|
|
1859
|
-
const itemInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
1860
|
-
function invalidateItem(itemId, priority = "highPriority", ignoreInvalidationSync = false) {
|
|
1861
|
-
if (!fetchItemOrquestrator) {
|
|
1862
|
-
throw new Error(noFetchFnError);
|
|
1863
|
-
}
|
|
1864
|
-
const itemsKey = getItemsKeyArray(itemId);
|
|
1865
|
-
for (const { itemKey, payload } of itemsKey) {
|
|
1866
|
-
const item = store.state.itemQueries[itemKey];
|
|
1867
|
-
if (!item)
|
|
1868
|
-
continue;
|
|
1869
|
-
const currentInvalidationPriority = item.refetchOnMount ? fetchTypePriority[item.refetchOnMount] : -1;
|
|
1870
|
-
const newInvalidationPriority = fetchTypePriority[priority];
|
|
1871
|
-
if (currentInvalidationPriority >= newInvalidationPriority)
|
|
1872
|
-
continue;
|
|
1873
|
-
store.produceState(
|
|
1874
|
-
(draft) => {
|
|
1875
|
-
const query = draft.itemQueries[itemKey];
|
|
1876
|
-
if (!query)
|
|
1877
|
-
return;
|
|
1878
|
-
query.refetchOnMount = priority;
|
|
1879
|
-
},
|
|
1880
|
-
{ action: { type: "invalidate-item", queryKey: itemKey } }
|
|
1881
|
-
);
|
|
1882
|
-
itemInvalidationWasTriggered.delete(itemKey);
|
|
1883
|
-
storeEvents.emit("invalidateItem", { priority, itemKey });
|
|
1884
|
-
if (onInvalidateItem) {
|
|
1885
|
-
const itemState = store.state.items[itemKey];
|
|
1886
|
-
if (itemState) {
|
|
1887
|
-
onInvalidateItem({
|
|
1888
|
-
priority,
|
|
1889
|
-
itemState,
|
|
1890
|
-
payload
|
|
1891
|
-
});
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
if (syncMutationsAndInvalidations && !ignoreInvalidationSync) {
|
|
1896
|
-
invalidateQuery(
|
|
1897
|
-
(query) => itemsKey.some(
|
|
1898
|
-
({ payload }) => syncMutationsAndInvalidations.syncItemAndQuery(payload, query)
|
|
1899
|
-
),
|
|
1900
|
-
priority,
|
|
1901
|
-
true
|
|
1902
|
-
);
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
1876
|
function startItemMutation(itemId) {
|
|
1906
1877
|
const itemsKey = getItemsKeyArray(itemId);
|
|
1907
1878
|
const endMutations = [];
|
|
1908
|
-
for (const { itemKey
|
|
1879
|
+
for (const { itemKey } of itemsKey) {
|
|
1909
1880
|
endMutations.push(
|
|
1910
1881
|
fetchItemOrquestrator?.get(itemKey).startMutation() || (() => {
|
|
1911
1882
|
})
|
|
1912
1883
|
);
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
)) {
|
|
1919
|
-
endMutations.push(
|
|
1920
|
-
fetchQueryOrquestrator.get(queryKey).startMutation()
|
|
1921
|
-
);
|
|
1922
|
-
}
|
|
1884
|
+
for (const [queryKey, query] of Object.entries(store.state.queries)) {
|
|
1885
|
+
if (query.items.includes(itemKey)) {
|
|
1886
|
+
endMutations.push(
|
|
1887
|
+
fetchQueryOrquestrator.get(queryKey).startMutation()
|
|
1888
|
+
);
|
|
1923
1889
|
}
|
|
1924
1890
|
}
|
|
1925
1891
|
}
|
|
@@ -2277,7 +2243,10 @@ function newTSDFListQueryStore({
|
|
|
2277
2243
|
}
|
|
2278
2244
|
});
|
|
2279
2245
|
if (queriesToInvalidate.length)
|
|
2280
|
-
|
|
2246
|
+
invalidateQueryAndItems({
|
|
2247
|
+
queryPayload: queriesToInvalidate,
|
|
2248
|
+
itemPayload: false
|
|
2249
|
+
});
|
|
2281
2250
|
}
|
|
2282
2251
|
function addItemToState(itemPayload, data, {
|
|
2283
2252
|
addItemToQueries
|
|
@@ -2360,8 +2329,7 @@ function newTSDFListQueryStore({
|
|
|
2360
2329
|
deleteItemState,
|
|
2361
2330
|
getItemState,
|
|
2362
2331
|
loadMore,
|
|
2363
|
-
|
|
2364
|
-
invalidateItem,
|
|
2332
|
+
invalidateQueryAndItems,
|
|
2365
2333
|
scheduleItemFetch,
|
|
2366
2334
|
awaitItemFetch,
|
|
2367
2335
|
awaitListQueryFetch,
|