mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-24 14:36:17 +01:00
refactoring (no functionality changes)
This commit is contained in:
@@ -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])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user