Add custom sorting to the twitch channels widget

this allows the channels to be sorted as defined in the config while
still keeping the live channels on the top. the wording could probably
be improved, "custom" is too broad but i'm not sure what else to call
it.
This commit is contained in:
fawn
2024-05-18 03:07:34 +03:00
parent 21d491843f
commit 0681a04607
3 changed files with 21 additions and 1 deletions

View File

@@ -44,6 +44,12 @@ func (channels TwitchChannels) SortByViewers() {
})
}
func (channels TwitchChannels) SortByLive() {
sort.SliceStable(channels, func(i, j int) bool {
return channels[i].IsLive && !channels[j].IsLive
})
}
type twitchOperationResponse struct {
Data json.RawMessage
Extensions struct {