if a already queued item is selected, it is moved to the front
This commit is contained in:
parent
6e4419dd61
commit
aad6ef5d72
1 changed files with 9 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -103,13 +102,19 @@ func (m *playerModel) View() string {
|
|||
func (m *playerModel) queue(f feedEntry) error {
|
||||
// check if already exists
|
||||
// TODO: handle actually showing errros?
|
||||
for _, e := range m.playQueue {
|
||||
queueIndex := -1
|
||||
for i, e := range m.playQueue {
|
||||
if e.ID == f.ID {
|
||||
return errors.New("already exists")
|
||||
queueIndex = i
|
||||
}
|
||||
}
|
||||
|
||||
m.playQueue = append(m.playQueue, f)
|
||||
if queueIndex >= 0 && len(m.playQueue) > 1 {
|
||||
m.playQueue = append([]feedEntry{f}, append(m.playQueue[:queueIndex], m.playQueue[queueIndex+1:]...)...)
|
||||
|
||||
} else {
|
||||
m.playQueue = append(m.playQueue, f)
|
||||
}
|
||||
|
||||
if len(m.playQueue) == 1 && m.mpv.IsPlaying() == false {
|
||||
m.currentlyPlaying = &m.playQueue[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue