From ebaf97e0361bdd779340b692395b196b86eb657e Mon Sep 17 00:00:00 2001 From: Avi Wadhwa Date: Tue, 19 Nov 2024 13:41:28 -0800 Subject: [PATCH] Make sure fetchBackgroundColor doesn't loop forever --- SpotifyLyricsInMenubar/viewModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SpotifyLyricsInMenubar/viewModel.swift b/SpotifyLyricsInMenubar/viewModel.swift index 620d245..20fa23b 100644 --- a/SpotifyLyricsInMenubar/viewModel.swift +++ b/SpotifyLyricsInMenubar/viewModel.swift @@ -299,7 +299,7 @@ import NaturalLanguage return Color(red: red/255, green: green/255, blue: blue/255) //(red, green, blue) } - func fetchBackgroundColor() { + func fetchBackgroundColor(retry: Bool = true) { guard let currentlyPlaying else { return } @@ -320,7 +320,9 @@ import NaturalLanguage if !currentlyPlayingLyrics.isEmpty, let currentlyPlayingName { Task { currentlyPlayingLyrics = try await fetchNetworkLyrics(for: currentlyPlaying, currentlyPlayingName, UserDefaults.standard.bool(forKey: "spotifyOrAppleMusic")) - fetchBackgroundColor() + if retry { + fetchBackgroundColor(retry: false) + } } } // No SongObject found with the given trackID