diff options
Diffstat (limited to 'src/app.go')
-rw-r--r-- | src/app.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -2,7 +2,9 @@ package src | |||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "math/rand" | ||
5 | "os" | 6 | "os" |
7 | "time" | ||
6 | 8 | ||
7 | "git.sixfoisneuf.fr/termsonic/music" | 9 | "git.sixfoisneuf.fr/termsonic/music" |
8 | "github.com/delucks/go-subsonic" | 10 | "github.com/delucks/go-subsonic" |
@@ -158,3 +160,13 @@ func (a *app) switchToPage(name string) { | |||
158 | 160 | ||
159 | a.updateFooter() | 161 | a.updateFooter() |
160 | } | 162 | } |
163 | |||
164 | func randomize(t []*subsonic.Child) []*subsonic.Child { | ||
165 | t2 := make([]*subsonic.Child, len(t)) | ||
166 | copy(t2, t) | ||
167 | |||
168 | rand.Seed(time.Now().UnixNano()) | ||
169 | rand.Shuffle(len(t2), func(i, j int) { t2[i], t2[j] = t2[j], t2[i] }) | ||
170 | |||
171 | return t2 | ||
172 | } | ||