From 641bb773c99a085d1f8de43ce5eb020592312782 Mon Sep 17 00:00:00 2001 From: "Andrei D." Date: Wed, 4 Jun 2025 23:26:53 +0300 Subject: [PATCH] maintain swift 5.8 compatibility. (#793) --- .../EeveeSpotify/Lyrics/CustomLyrics.x.swift | 21 +++++++++++++----- .../Lyrics/Models/LyricsError.swift | 22 +++++++++++++------ .../Lyrics/Models/Settings/LyricsSource.swift | 21 ++++++++++++------ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift index 5877ee0..c1ee671 100644 --- a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift @@ -170,13 +170,22 @@ private func loadLyricsForCurrentTrack() throws { let options = UserDefaults.lyricsOptions var source = UserDefaults.lyricsSource - var repository: LyricsRepository = switch source { - case .genius: geniusLyricsRepository - case .lrclib: LrclibLyricsRepository.shared - case .musixmatch: MusixmatchLyricsRepository.shared - case .petit: petitLyricsRepository - case .notReplaced: throw LyricsError.invalidSource + // switched to swift 5.8 syntax to compile with Theos on Linux. + var repository: LyricsRepository + + switch source { + case .genius: + repository = geniusLyricsRepository + case .lrclib: + repository = LrclibLyricsRepository.shared + case .musixmatch: + repository = MusixmatchLyricsRepository.shared + case .petit: + repository = petitLyricsRepository + case .notReplaced: + throw LyricsError.invalidSource } + let lyricsDto: LyricsDto diff --git a/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift b/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift index aa44a83..db71bb1 100644 --- a/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift +++ b/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift @@ -9,15 +9,23 @@ enum LyricsError: Error, CustomStringConvertible { case unknownError case invalidSource + // swift 5.8 compatible var description: String { switch self { - case .noSuchSong: "no_such_song".localized - case .musixmatchRestricted: "musixmatch_restricted".localized - case .invalidMusixmatchToken: "invalid_musixmatch_token".localized - case .decodingError: "decoding_error".localized - case .noCurrentTrack: "no_current_track".localized - case .unknownError: "unknown_error".localized - case .invalidSource: "" + case .noSuchSong: + return "no_such_song".localized + case .musixmatchRestricted: + return "musixmatch_restricted".localized + case .invalidMusixmatchToken: + return "invalid_musixmatch_token".localized + case .decodingError: + return "decoding_error".localized + case .noCurrentTrack: + return "no_current_track".localized + case .unknownError: + return "unknown_error".localized + case .invalidSource: + return "" } } } diff --git a/Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsSource.swift b/Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsSource.swift index 2944289..506b67d 100644 --- a/Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsSource.swift +++ b/Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsSource.swift @@ -11,15 +11,22 @@ enum LyricsSource: Int, CaseIterable, CustomStringConvertible { return [.genius, .lrclib, .musixmatch, .petit] } + // swift 5.8 compatible var description: String { - switch self { - case .genius: "Genius" - case .lrclib: "LRCLIB" - case .musixmatch: "Musixmatch" - case .petit: "PetitLyrics" - case .notReplaced: "Spotify" - } + switch self { + case .genius: + return "Genius" + case .lrclib: + return "LRCLIB" + case .musixmatch: + return "Musixmatch" + case .petit: + return "PetitLyrics" + case .notReplaced: + return "Spotify" } + } + var isReplacingLyrics: Bool { self != .notReplaced }