From 18ac2b7532879d86178c03ac07630838aaeff6a0 Mon Sep 17 00:00:00 2001 From: Th0rn0 Date: Fri, 27 Sep 2024 16:59:13 +0100 Subject: [PATCH] skip fix --- api/player.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/api/player.go b/api/player.go index 92df525..b9d1b07 100644 --- a/api/player.go +++ b/api/player.go @@ -60,6 +60,14 @@ func handlePlayer(c *gin.Context) { currentDevice.Volume = handleTrackVolumeInput.Volume case "skip": track, _ := getNextSongExcludeURI(currentTrackURI) + banQuery := c.Query("ban") + if banQuery == "true" { + _, err := addBannedTrack(currentTrackURI) + if err != nil { + c.JSON(http.StatusInternalServerError, err) + return + } + } playerOpt.URIs = []spotify.URI{track.URI} err = client.NextOpt(ctx, &playerOpt) if err != nil { @@ -68,19 +76,12 @@ func handlePlayer(c *gin.Context) { return } if !fallbackPlaylist.Active { - if err := db.First(&track, Track{URI: currentTrackURI}).Error; err != nil { + var currentTrack Track + if err := db.First(¤tTrack, Track{URI: currentTrackURI}).Error; err != nil { c.JSON(http.StatusNotFound, "Track Not Found") return } - if err := db.Unscoped().Delete(&track).Error; err != nil { - c.JSON(http.StatusInternalServerError, err) - return - } - } - banQuery := c.Query("ban") - if banQuery == "true" { - _, err := addBannedTrack(currentTrackURI) - if err != nil { + if err := db.Unscoped().Delete(¤tTrack).Error; err != nil { c.JSON(http.StatusInternalServerError, err) return }