refactor 2: use generic model for grid view

This commit is contained in:
Drew Weymouth
2023-04-28 17:25:57 -07:00
parent cf4540eb32
commit 753e7f9bcc
7 changed files with 95 additions and 65 deletions
+8
View File
@@ -35,6 +35,14 @@ func FilterSlice[T any](ss []T, test func(T) bool) []T {
return result
}
func MapSlice[T any, U any](ts []T, f func(T) U) []U {
result := make([]U, len(ts))
for i, t := range ts {
result[i] = f(t)
}
return result
}
func FindTrackByID(id string, tracks []*subsonic.Child) *subsonic.Child {
for _, tr := range tracks {
if id == tr.ID {