From 6eeddda97669258cc5b7ba175a3c98d598a2871f Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Thu, 5 Mar 2026 15:02:11 -0500 Subject: [PATCH] refactor(quick-14): make playOrLoadCurrentTrack and playCurrentTrack return bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - playCurrentTrack returns false on load failure or play error - playOrLoadCurrentTrack propagates bool from load/play helpers - loadCurrentTrack already returned bool — no change needed --- backend/queue/queue.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/queue/queue.go b/backend/queue/queue.go index 22b74f6..0fb8eec 100644 --- a/backend/queue/queue.go +++ b/backend/queue/queue.go @@ -1115,12 +1115,13 @@ func (q *Queue) EmitCurrentState() { // playOrLoadCurrentTrack loads the current track and optionally starts // playback. When autoPlay is true it behaves like playCurrentTrack; // when false it only loads the file (leaving the player paused). -func (q *Queue) playOrLoadCurrentTrack(autoPlay bool) { +// Returns true if the file was loaded (and optionally played) successfully. +func (q *Queue) playOrLoadCurrentTrack(autoPlay bool) bool { if autoPlay { - q.playCurrentTrack() - } else { - q.loadCurrentTrack() + return q.playCurrentTrack() } + + return q.loadCurrentTrack() } // loadCurrentTrack tells the player to load the current track without @@ -1166,9 +1167,10 @@ func (q *Queue) loadCurrentTrack() bool { } // playCurrentTrack tells the player to load and play the current track. -func (q *Queue) playCurrentTrack() { +// Returns true if the file was loaded and playback started successfully. +func (q *Queue) playCurrentTrack() bool { if !q.loadCurrentTrack() { - return + return false } err := q.player.Play() @@ -1178,7 +1180,11 @@ func (q *Queue) playCurrentTrack() { "Failed to play file from queue", "filePath", track.FilePath, "err", err, ) + + return false } + + return true } // handleCurrentTrackRemoved handles the case where the currently loaded