From efb03c1aadbb8aafbd739ee1e0c77d8c540d1083 Mon Sep 17 00:00:00 2001 From: abs3nt Date: Sun, 16 Apr 2023 10:58:50 -0700 Subject: [PATCH] fix skipping within queue while playing in a context --- cmd/next.go | 2 +- src/commands/commands.go | 8 +++++++- src/tui/handlers.go | 6 +++--- src/tui/main.go | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/next.go b/cmd/next.go index d5c9f72..332bc2f 100644 --- a/cmd/next.go +++ b/cmd/next.go @@ -25,6 +25,6 @@ var nextCmd = &cobra.Command{ return err } } - return commands.Next(ctx, skipAmt) + return commands.Next(ctx, skipAmt, false) }, } diff --git a/src/commands/commands.go b/src/commands/commands.go index 23549d5..164b878 100644 --- a/src/commands/commands.go +++ b/src/commands/commands.go @@ -793,7 +793,13 @@ func (c *Commands) Unlike(ctx *gctx.Context) error { return nil } -func (c *Commands) Next(ctx *gctx.Context, amt int) error { +func (c *Commands) Next(ctx *gctx.Context, amt int, inqueue bool) error { + if inqueue { + for i := 0; i < amt; i++ { + c.Client().Next(ctx) + } + return nil + } if amt == 1 { err := c.Client().Next(ctx) if err != nil { diff --git a/src/tui/handlers.go b/src/tui/handlers.go index 5f789d2..572bead 100644 --- a/src/tui/handlers.go +++ b/src/tui/handlers.go @@ -86,14 +86,14 @@ func HandlePlayTrack(ctx *gctx.Context, commands *commands.Commands, track spoti if err != nil { return } - err = commands.Next(ctx, 1) + err = commands.Next(ctx, 1, false) if err != nil { return } } -func HandleSkipWithinContext(ctx *gctx.Context, commands *commands.Commands, amt int) { - err := commands.Next(ctx, amt) +func HandleNextInQueue(ctx *gctx.Context, commands *commands.Commands, amt int) { + err := commands.Next(ctx, amt, true) if err != nil { return } diff --git a/src/tui/main.go b/src/tui/main.go index 861aab2..fddbe87 100644 --- a/src/tui/main.go +++ b/src/tui/main.go @@ -276,7 +276,7 @@ func (m *mainModel) SelectItem() error { case Queue: page = 1 go func() { - HandleSkipWithinContext(m.ctx, m.commands, m.list.Index()) + HandleNextInQueue(m.ctx, m.commands, m.list.Index()) new_items, err := QueueView(m.ctx, m.commands) if err != nil { return