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,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('Для интерфейсов на странице нет рекомендаций оптимизатора');
|
||||||
|
|||||||
Reference in New Issue
Block a user