sort disabled to bot

This commit is contained in:
Bel LaPointe
2025-05-24 14:24:16 -06:00
parent 3f7c13a6be
commit ce0750db66
2 changed files with 10 additions and 3 deletions

View File

@@ -2,12 +2,13 @@ package server
import (
"encoding/json"
"net/http"
"sort"
"gitea.inhome.blapointe.com/local/firestormy/config"
"gitea.inhome.blapointe.com/local/firestormy/config/ns"
"gitea.inhome.blapointe.com/local/firestormy/scheduler"
"gitea.inhome.blapointe.com/local/logb"
"net/http"
"sort"
)
func (s *Server) list(w http.ResponseWriter, r *http.Request) {
@@ -34,6 +35,12 @@ func (s *Server) list(w http.ResponseWriter, r *http.Request) {
out[i] = toMap(j, false)
}
sort.Slice(out, func(i, j int) bool {
if out[i]["disabled"].(bool) == out[j]["disabled"].(bool) {
} else if out[i]["disabled"].(bool) {
return false
} else if out[j]["disabled"].(bool) {
return true
}
return out[i]["title"].(string) < out[j]["title"].(string)
})
json.NewEncoder(w).Encode(out)