refactor(OspfToolsPage): streamline template cost updates by consolidating state management logic
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m55s

This commit is contained in:
2026-03-15 21:44:37 +07:00
parent b9d45bb8b7
commit 164507513c
+11 -12
View File
@@ -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('Для интерфейсов на странице нет рекомендаций оптимизатора');