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
+3 -4
View File
@@ -320,8 +320,7 @@ export default function OspfToolsPage() {
let changedCount = 0; let changedCount = 0;
let hintedCount = 0; let hintedCount = 0;
setTemplates((prev) => const nextTemplates = (templates || []).map((item) => {
prev.map((item) => {
const hintKey = `${item.routerKey}::${item.area}::${String(item.interfaceName || '').toUpperCase()}`; const hintKey = `${item.routerKey}::${item.area}::${String(item.interfaceName || '').toUpperCase()}`;
const hint = hints[hintKey]; const hint = hints[hintKey];
if (!hint) return item; if (!hint) return item;
@@ -330,8 +329,8 @@ export default function OspfToolsPage() {
if (!Number.isFinite(nextCost) || nextCost < 0 || Number(item.cost) === nextCost) return item; if (!Number.isFinite(nextCost) || nextCost < 0 || Number(item.cost) === nextCost) return item;
changedCount += 1; changedCount += 1;
return { ...item, cost: nextCost }; return { ...item, cost: nextCost };
}) });
); setTemplates(nextTemplates);
if (hintedCount === 0) { if (hintedCount === 0) {
notify.warning('Для интерфейсов на странице нет рекомендаций оптимизатора'); notify.warning('Для интерфейсов на странице нет рекомендаций оптимизатора');