Add ability to reorder playlist items

This commit is contained in:
Deluan
2020-06-04 19:05:41 -04:00
parent b597a34cb4
commit 331fa1d952
8 changed files with 158 additions and 34 deletions
+13
View File
@@ -25,3 +25,16 @@ func StringInSlice(a string, list []string) bool {
}
return false
}
func InsertString(array []string, value string, index int) []string {
return append(array[:index], append([]string{value}, array[index:]...)...)
}
func RemoveString(array []string, index int) []string {
return append(array[:index], array[index+1:]...)
}
func MoveString(array []string, srcIndex int, dstIndex int) []string {
value := array[srcIndex]
return InsertString(RemoveString(array, srcIndex), value, dstIndex)
}