begin the refactoring - doesnt compile
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"math"
|
||||
"sort"
|
||||
|
||||
"github.com/dweymouth/go-subsonic/subsonic"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
)
|
||||
|
||||
func SliceContains[T comparable](ts []T, t T) bool {
|
||||
@@ -40,7 +40,7 @@ func MapSlice[T any, U any](ts []T, f func(T) U) []U {
|
||||
return result
|
||||
}
|
||||
|
||||
func FindTrackByID(id string, tracks []*subsonic.Child) *subsonic.Child {
|
||||
func FindTrackByID(id string, tracks []*mediaprovider.Track) *mediaprovider.Track {
|
||||
for _, tr := range tracks {
|
||||
if id == tr.ID {
|
||||
return tr
|
||||
@@ -49,15 +49,15 @@ func FindTrackByID(id string, tracks []*subsonic.Child) *subsonic.Child {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TrackIDOrEmptyStr(track *subsonic.Child) string {
|
||||
func TrackIDOrEmptyStr(track *mediaprovider.Track) string {
|
||||
if track == nil {
|
||||
return ""
|
||||
}
|
||||
return track.ID
|
||||
}
|
||||
|
||||
func TracksToIDs(tracks []*subsonic.Child) []string {
|
||||
return MapSlice(tracks, func(tr *subsonic.Child) string {
|
||||
func TracksToIDs(tracks []*mediaprovider.Track) []string {
|
||||
return MapSlice(tracks, func(tr *mediaprovider.Track) string {
|
||||
return tr.ID
|
||||
})
|
||||
}
|
||||
@@ -73,8 +73,8 @@ const (
|
||||
|
||||
// Reorder tracks and return a new track slice.
|
||||
// idxToMove must contain only valid indexes into tracks, and no repeats
|
||||
func ReorderTracks(tracks []*subsonic.Child, idxToMove []int, op TrackReorderOp) []*subsonic.Child {
|
||||
newTracks := make([]*subsonic.Child, len(tracks))
|
||||
func ReorderTracks(tracks []*mediaprovider.Track, idxToMove []int, op TrackReorderOp) []*mediaprovider.Track {
|
||||
newTracks := make([]*mediaprovider.Track, len(tracks))
|
||||
switch op {
|
||||
case MoveToTop:
|
||||
topIdx := 0
|
||||
|
||||
@@ -3,11 +3,11 @@ package sharedutil
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/dweymouth/go-subsonic/subsonic"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
)
|
||||
|
||||
func Test_ReorderTracks(t *testing.T) {
|
||||
tracks := []*subsonic.Child{
|
||||
tracks := []*mediaprovider.Track{
|
||||
{ID: "a"}, // 0
|
||||
{ID: "b"}, // 1
|
||||
{ID: "c"}, // 2
|
||||
@@ -18,7 +18,7 @@ func Test_ReorderTracks(t *testing.T) {
|
||||
|
||||
// test MoveToTop:
|
||||
idxToMove := []int{0, 2, 3, 5}
|
||||
want := []*subsonic.Child{
|
||||
want := []*mediaprovider.Track{
|
||||
{ID: "a"},
|
||||
{ID: "c"},
|
||||
{ID: "d"},
|
||||
@@ -33,7 +33,7 @@ func Test_ReorderTracks(t *testing.T) {
|
||||
|
||||
// test MoveToBottom:
|
||||
idxToMove = []int{0, 2, 5}
|
||||
want = []*subsonic.Child{
|
||||
want = []*mediaprovider.Track{
|
||||
{ID: "b"},
|
||||
{ID: "d"},
|
||||
{ID: "e"},
|
||||
@@ -48,7 +48,7 @@ func Test_ReorderTracks(t *testing.T) {
|
||||
|
||||
// test MoveUp:
|
||||
idxToMove = []int{0, 1, 3, 5}
|
||||
want = []*subsonic.Child{
|
||||
want = []*mediaprovider.Track{
|
||||
{ID: "a"},
|
||||
{ID: "b"},
|
||||
{ID: "d"},
|
||||
@@ -63,7 +63,7 @@ func Test_ReorderTracks(t *testing.T) {
|
||||
|
||||
// test MoveDown:
|
||||
idxToMove = []int{2, 4, 5}
|
||||
want = []*subsonic.Child{
|
||||
want = []*mediaprovider.Track{
|
||||
{ID: "a"},
|
||||
{ID: "b"},
|
||||
{ID: "d"},
|
||||
@@ -77,7 +77,7 @@ func Test_ReorderTracks(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func tracklistsEqual(t *testing.T, a, b []*subsonic.Child) bool {
|
||||
func tracklistsEqual(t *testing.T, a, b []*mediaprovider.Track) bool {
|
||||
t.Helper()
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user