maintain swift 5.8 compatibility. (#793)

This commit is contained in:
Andrei D.
2025-06-04 23:26:53 +03:00
committed by GitHub
parent 3e0a69dea0
commit 641bb773c9
3 changed files with 44 additions and 20 deletions
@@ -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
@@ -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 ""
}
}
}
@@ -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 }