refactoring (no functionality changes)

This commit is contained in:
henrygd
2025-08-02 17:04:38 -04:00
parent aa2bc9f118
commit a0f271545a
8 changed files with 489 additions and 471 deletions

View File

@@ -72,18 +72,18 @@ function AlertDialogContent({ system }: { system: SystemRecord }) {
const alerts = useStore($alerts)
const [overwriteExisting, setOverwriteExisting] = useState<boolean | "indeterminate">(false)
// alertsSignature changes only when alerts for this system change
let alertsSignature = ""
/* key to prevent re-rendering */
const alertsSignature: string[] = []
const systemAlerts = alerts.filter((alert) => {
if (alert.system === system.id) {
alertsSignature += alert.name + alert.min + alert.value
alertsSignature.push(alert.name, alert.min, alert.value)
return true
}
return false
}) as AlertRecord[]
return useMemo(() => {
// console.log("render modal", system.name, alertsSignature)
const data = Object.keys(alertInfo).map((name) => {
const alert = alertInfo[name as keyof typeof alertInfo]
return {
@@ -149,5 +149,5 @@ function AlertDialogContent({ system }: { system: SystemRecord }) {
</Tabs>
</>
)
}, [alertsSignature, overwriteExisting])
}, [alertsSignature.join(""), overwriteExisting])
}