Reprioritize notification services when updated.

This commit is contained in:
Magnus Åhall 2024-07-04 19:36:56 +02:00
parent 257a4968ec
commit 414ca0a95c
2 changed files with 5 additions and 0 deletions

View File

@ -1211,6 +1211,8 @@ func actionConfigurationNotificationUpdate(w http.ResponseWriter, r *http.Reques
notificationManager.AddService(*svc)
}
notificationManager.Reprioritize()
w.Header().Add("Location", "/configuration")
w.WriteHeader(302)
} // }}}

View File

@ -39,6 +39,9 @@ func NewManager(logger *slog.Logger) (nm Manager) {
func (nm *Manager) AddService(service Service) {
service.SetExists(true)
nm.services = append(nm.services, service)
}
func (nm *Manager) Reprioritize() {
slices.SortFunc(nm.services, func(a, b Service) int {
if a.GetPrio() < b.GetPrio() {
return -1