From 5e952e389951cda6c32a4025ec023960eff861cf Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:12:11 +0200 Subject: [PATCH] Fix delay of one second when switching at song end --- src/preload.js | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/preload.js b/src/preload.js index f0efb77..0501635 100644 --- a/src/preload.js +++ b/src/preload.js @@ -277,29 +277,30 @@ setInterval(function () { currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; - // check progress bar value and make sure current stays up to date after switch - if(barvalue != barval) { - barvalue = barval; - oldcurrent = options.current; - updatecurrent = true; - } - - if(updatecurrent) { - if(options.current == oldcurrent && currentStatus != "paused") return; - oldcurrent = options.current; - updatecurrent = false; - } - // make sure current is set to 0 if title changes - if(titleOrArtistChanged) { + if (titleOrArtistChanged) { options.current = "0:00"; + oldcurrent = options.current; barvalue = barval; - } + } else { + // check progress bar value and make sure current stays up to date after switch + if (barvalue != barval) { + barvalue = barval; + oldcurrent = options.current; + updatecurrent = true; + } - if(durationChanged) { - options.duration = duration; - options.current = current; - sduration = duration; + if (updatecurrent) { + if (options.current == oldcurrent && currentStatus != "paused") return; + oldcurrent = options.current; + updatecurrent = false; + } + + if (durationChanged) { + options.duration = duration; + options.current = current; + sduration = duration; + } } const image = elements.getSongIcon();