From fc0b9f0d67623bb5469ffba7f7fd77e6e5e0d00f Mon Sep 17 00:00:00 2001 From: Avi Wadhwa Date: Sat, 20 Apr 2024 15:02:27 -0700 Subject: [PATCH] Set "show lyrics" to a state variable instead of app storage. "Don't Show Lyrics" is not saved in userdefaults anymore. Patched some cases where lyrics would update when showLyrics was false. --- SpotifyLyricsInMenubar/SpotifyLyricsInMenubarApp.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SpotifyLyricsInMenubar/SpotifyLyricsInMenubarApp.swift b/SpotifyLyricsInMenubar/SpotifyLyricsInMenubarApp.swift index 123c1a7..a1ada8c 100644 --- a/SpotifyLyricsInMenubar/SpotifyLyricsInMenubarApp.swift +++ b/SpotifyLyricsInMenubar/SpotifyLyricsInMenubarApp.swift @@ -14,7 +14,7 @@ struct SpotifyLyricsInMenubarApp: App { @AppStorage("launchOnLogin") var launchOnLogin: Bool = false // True: means Apple Music, False: Spotify @AppStorage("spotifyOrAppleMusic") var spotifyOrAppleMusic: Bool = false - @AppStorage("showLyrics") var showLyrics: Bool = true + @State var showLyrics: Bool = true @AppStorage("hasOnboarded") var hasOnboarded: Bool = false @AppStorage("truncationLength") var truncationLength: Int = 40 @Environment(\.openWindow) var openWindow @@ -32,7 +32,7 @@ struct SpotifyLyricsInMenubarApp: App { } viewmodel.currentlyPlayingLyrics = try await viewmodel.fetchNetworkLyrics(for: currentlyPlaying, currentlyPlayingName, spotifyOrAppleMusic) print("HELLOO") - if viewmodel.isPlaying, !viewmodel.currentlyPlayingLyrics.isEmpty { + if viewmodel.isPlaying, !viewmodel.currentlyPlayingLyrics.isEmpty, showLyrics { viewmodel.startLyricUpdater(appleMusicOrSpotify: spotifyOrAppleMusic) } } @@ -236,7 +236,7 @@ struct SpotifyLyricsInMenubarApp: App { Task { if let nowPlaying, let currentlyPlayingName = viewmodel.currentlyPlayingName, let lyrics = await viewmodel.fetch(for: nowPlaying, currentlyPlayingName, spotifyOrAppleMusic) { viewmodel.currentlyPlayingLyrics = lyrics - if viewmodel.isPlaying, !viewmodel.currentlyPlayingLyrics.isEmpty { + if viewmodel.isPlaying, !viewmodel.currentlyPlayingLyrics.isEmpty, showLyrics { print("STARTING UPDATER") viewmodel.startLyricUpdater(appleMusicOrSpotify: spotifyOrAppleMusic) }