refactor(OspfToolsPage): streamline template cost updates by consolidating state management logic
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m55s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m55s
This commit is contained in:
@@ -320,18 +320,17 @@ export default function OspfToolsPage() {
|
||||
|
||||
let changedCount = 0;
|
||||
let hintedCount = 0;
|
||||
setTemplates((prev) =>
|
||||
prev.map((item) => {
|
||||
const hintKey = `${item.routerKey}::${item.area}::${String(item.interfaceName || '').toUpperCase()}`;
|
||||
const hint = hints[hintKey];
|
||||
if (!hint) return item;
|
||||
hintedCount += 1;
|
||||
const nextCost = Number(hint.optimalCost);
|
||||
if (!Number.isFinite(nextCost) || nextCost < 0 || Number(item.cost) === nextCost) return item;
|
||||
changedCount += 1;
|
||||
return { ...item, cost: nextCost };
|
||||
})
|
||||
);
|
||||
const nextTemplates = (templates || []).map((item) => {
|
||||
const hintKey = `${item.routerKey}::${item.area}::${String(item.interfaceName || '').toUpperCase()}`;
|
||||
const hint = hints[hintKey];
|
||||
if (!hint) return item;
|
||||
hintedCount += 1;
|
||||
const nextCost = Number(hint.optimalCost);
|
||||
if (!Number.isFinite(nextCost) || nextCost < 0 || Number(item.cost) === nextCost) return item;
|
||||
changedCount += 1;
|
||||
return { ...item, cost: nextCost };
|
||||
});
|
||||
setTemplates(nextTemplates);
|
||||
|
||||
if (hintedCount === 0) {
|
||||
notify.warning('Для интерфейсов на странице нет рекомендаций оптимизатора');
|
||||
|
||||
Reference in New Issue
Block a user