Replaced labels with icons in the SR and Action badges
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
function createProductActivities({ productsContentState, opportunitiesQueryState, resetCrm,
|
||||
loadCrm, loadActions, render }) {
|
||||
function createProductActivities({ productsContentState, opportunitiesQueryState,
|
||||
loadCrm, loadActions, blockActions, render }) {
|
||||
let cycle = null;
|
||||
function begin(requestId, token) {
|
||||
cycle = { requestId, token, version: opportunitiesQueryState.periodRequestVersion, completed: false };
|
||||
@@ -11,26 +11,32 @@ function createProductActivities({ productsContentState, opportunitiesQueryState
|
||||
current.completed = true;
|
||||
const products = [...productsContentState.opptyProductsByNumber.values()].filter(result => !result.error);
|
||||
if (!products.length) return;
|
||||
resetCrm();
|
||||
const pending = [];
|
||||
const seen = new Set();
|
||||
for (const result of products) {
|
||||
const items = result.items.filter(item => {
|
||||
const id = String(item?.RevnId ?? "");
|
||||
if (seen.has(id)) return false;
|
||||
seen.add(id);
|
||||
return true;
|
||||
});
|
||||
pending.push(loadActions({ ...result, items }, true, { cachedAt: result.cachedAt, cacheOnly: result.fromCache === true }));
|
||||
}
|
||||
const cachedAt = Math.max(...products.map(result => Number(result.cachedAt) || 0));
|
||||
pending.push(loadCrm(current.token, current.version, { cachedAt, cacheOnly: products.every(result => result.fromCache) }));
|
||||
return Promise.allSettled(pending).then(() => {
|
||||
if (cycle !== current || productsContentState.currentProductsRequestId !== requestId
|
||||
|| opportunitiesQueryState.periodRequestVersion !== current.version) return;
|
||||
const isActive = () => cycle === current && productsContentState.currentProductsRequestId === requestId
|
||||
&& opportunitiesQueryState.periodRequestVersion === current.version;
|
||||
return Promise.resolve(loadCrm(current.token, current.version, { cachedAt, cacheOnly: products.every(result => result.fromCache) })).then(async success => {
|
||||
if (!isActive()) return;
|
||||
if (success === false) {
|
||||
products.forEach(blockActions);
|
||||
render();
|
||||
return;
|
||||
}
|
||||
const pending = [];
|
||||
const seen = new Set();
|
||||
for (const result of products) {
|
||||
const items = result.items.filter(item => {
|
||||
const id = String(item?.RevnId ?? "");
|
||||
if (seen.has(id)) return false;
|
||||
seen.add(id);
|
||||
return true;
|
||||
});
|
||||
pending.push(loadActions({ ...result, items }, true, { cachedAt: result.cachedAt, cacheOnly: result.fromCache === true }));
|
||||
}
|
||||
await Promise.allSettled(pending);
|
||||
if (!isActive()) return;
|
||||
if (cachedAt > 0) productsContentState.productsLastCachedAt = cachedAt;
|
||||
render();
|
||||
}).catch(() => {});
|
||||
}).catch(() => { if (isActive()) { products.forEach(blockActions); render(); } });
|
||||
}
|
||||
return { begin, complete };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user