refactor: add subscribe / unsubscribe to alertManager

This commit is contained in:
henrygd
2025-08-24 19:48:21 -04:00
parent b64318d9e8
commit 0638ff3c21
3 changed files with 34 additions and 13 deletions

View File

@@ -38,10 +38,17 @@ const App = memo(() => {
})
// get servers / alerts / settings
updateUserSettings()
// get alerts after system list is loaded
updateSystemList().then(alertManager.refresh)
// need to get system list before alerts
updateSystemList()
// get alerts
.then(alertManager.refresh)
// subscribe to new alert updates
.then(alertManager.subscribe)
return () => updateFavicon("favicon.svg")
return () => {
updateFavicon("favicon.svg")
alertManager.unsubscribe()
}
}, [])
// update favicon
@@ -54,7 +61,8 @@ const App = memo(() => {
if (system.status === SystemStatus.Down) {
updateFavicon("favicon-red.svg")
return
} else if (system.status === SystemStatus.Up) {
}
if (system.status === SystemStatus.Up) {
up = true
}
}