Refactor alias filter handling in Svelte components to prevent unnecessary updates
Publish telemt-api gateway Docker image / test (push) Successful in 26s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 2m22s

- Added a check to prevent alias filter changes from triggering updates if the selected alias remains the same.
- Introduced a reactive effect to apply alias changes only when the component is rendered in the browser, improving performance and clarity in data handling.
This commit is contained in:
Denozordec
2026-04-10 16:17:54 +07:00
parent 12539a22ae
commit b68ca985d3
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -236,6 +236,7 @@
}
async function handleAliasFilterChange(nextAlias: string) {
if (nextAlias === aliasFilter) return;
aliasFilter = nextAlias;
await applyAliasIfChanged(nextAlias);
}
@@ -251,6 +252,12 @@ async function handleAliasFilterChange(nextAlias: string) {
void load();
});
$effect(() => {
if (typeof window === 'undefined') return;
const nextAlias = aliasFilter;
void applyAliasIfChanged(nextAlias);
});
let staleSeconds = $derived.by(() =>
lastSuccessAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastSuccessAtMs) / 1000))
);
+7
View File
@@ -135,6 +135,7 @@
}
async function handleAliasFilterChange(nextAlias: string) {
if (nextAlias === aliasFilter) return;
aliasFilter = nextAlias;
await applyAliasIfChanged(nextAlias);
}
@@ -151,6 +152,12 @@
void load();
});
$effect(() => {
if (typeof window === 'undefined') return;
const nextAlias = aliasFilter;
void applyAliasIfChanged(nextAlias);
});
let staleSeconds = $derived.by(() =>
lastSuccessAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastSuccessAtMs) / 1000))
);