Ensure channels are sorted

This commit is contained in:
Tim Van Baak 2025-02-09 16:30:22 -08:00
parent f5e9a0faec
commit dcd5c1e229

View File

@ -2,6 +2,7 @@ package web
import ( import (
"net/http" "net/http"
"sort"
"github.com/Jaculabilis/intake/core" "github.com/Jaculabilis/intake/core"
"github.com/Jaculabilis/intake/web/html" "github.com/Jaculabilis/intake/web/html"
@ -26,9 +27,14 @@ func (env *Env) getRoot(writer http.ResponseWriter, req *http.Request) {
if err != nil { if err != nil {
http.Error(writer, err.Error(), 500) http.Error(writer, err.Error(), 500)
} }
var channelNames []string
for name := range channels {
channelNames = append(channelNames, name)
}
sort.Strings(channelNames)
var channelData []html.ChannelData var channelData []html.ChannelData
for name, active := range channels { for _, name := range channelNames {
channelData = append(channelData, html.ChannelData{Name: name, Active: active}) channelData = append(channelData, html.ChannelData{Name: name, Active: channels[name]})
} }
data := html.HomeData{ data := html.HomeData{