Add inactive item fallback for dashboard change feed lookups
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
+5
-2
@@ -116,8 +116,11 @@ export async function listGroupedStockEntries(store, options = {}) {
|
||||
return fetchAllListPages(store, `${getPath('items')}/grouped`, baseQuery);
|
||||
}
|
||||
|
||||
export async function getStockEntry(store, stockId) {
|
||||
const payload = await apiRequest(store, `${getPath('items')}/${stockId}`);
|
||||
export async function getStockEntry(store, stockId, { allowInactive = false } = {}) {
|
||||
const path = `${getPath('items')}/${stockId}`;
|
||||
const payload = allowInactive
|
||||
? await apiRequest(store, path, { query: { allow_inactive: 1 } })
|
||||
: await apiRequest(store, path);
|
||||
return unwrapEntryPayload(payload);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,18 @@ export function dashboardPageData(store) {
|
||||
|
||||
if (missingItemUuids.length) {
|
||||
const results = await Promise.allSettled(
|
||||
missingItemUuids.map((uuid) => getStockEntry(store, uuid)),
|
||||
missingItemUuids.map(async (uuid) => {
|
||||
try {
|
||||
return await getStockEntry(store, uuid);
|
||||
} catch (error) {
|
||||
const status = error?.status || error?.cause?.status;
|
||||
if (status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return getStockEntry(store, uuid, { allowInactive: true });
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
results.forEach((result) => {
|
||||
|
||||
Reference in New Issue
Block a user