Skip to content

Commit 641bb77

Browse files
authored
maintain swift 5.8 compatibility. (#793)
1 parent 3e0a69d commit 641bb77

3 files changed

Lines changed: 44 additions & 20 deletions

File tree

Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,22 @@ private func loadLyricsForCurrentTrack() throws {
170170
let options = UserDefaults.lyricsOptions
171171
var source = UserDefaults.lyricsSource
172172

173-
var repository: LyricsRepository = switch source {
174-
case .genius: geniusLyricsRepository
175-
case .lrclib: LrclibLyricsRepository.shared
176-
case .musixmatch: MusixmatchLyricsRepository.shared
177-
case .petit: petitLyricsRepository
178-
case .notReplaced: throw LyricsError.invalidSource
173+
// switched to swift 5.8 syntax to compile with Theos on Linux.
174+
var repository: LyricsRepository
175+
176+
switch source {
177+
case .genius:
178+
repository = geniusLyricsRepository
179+
case .lrclib:
180+
repository = LrclibLyricsRepository.shared
181+
case .musixmatch:
182+
repository = MusixmatchLyricsRepository.shared
183+
case .petit:
184+
repository = petitLyricsRepository
185+
case .notReplaced:
186+
throw LyricsError.invalidSource
179187
}
188+
180189

181190
let lyricsDto: LyricsDto
182191

Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ enum LyricsError: Error, CustomStringConvertible {
99
case unknownError
1010
case invalidSource
1111

12+
// swift 5.8 compatible
1213
var description: String {
1314
switch self {
14-
case .noSuchSong: "no_such_song".localized
15-
case .musixmatchRestricted: "musixmatch_restricted".localized
16-
case .invalidMusixmatchToken: "invalid_musixmatch_token".localized
17-
case .decodingError: "decoding_error".localized
18-
case .noCurrentTrack: "no_current_track".localized
19-
case .unknownError: "unknown_error".localized
20-
case .invalidSource: ""
15+
case .noSuchSong:
16+
return "no_such_song".localized
17+
case .musixmatchRestricted:
18+
return "musixmatch_restricted".localized
19+
case .invalidMusixmatchToken:
20+
return "invalid_musixmatch_token".localized
21+
case .decodingError:
22+
return "decoding_error".localized
23+
case .noCurrentTrack:
24+
return "no_current_track".localized
25+
case .unknownError:
26+
return "unknown_error".localized
27+
case .invalidSource:
28+
return ""
2129
}
2230
}
2331
}

Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsSource.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ enum LyricsSource: Int, CaseIterable, CustomStringConvertible {
1111
return [.genius, .lrclib, .musixmatch, .petit]
1212
}
1313

14+
// swift 5.8 compatible
1415
var description: String {
15-
switch self {
16-
case .genius: "Genius"
17-
case .lrclib: "LRCLIB"
18-
case .musixmatch: "Musixmatch"
19-
case .petit: "PetitLyrics"
20-
case .notReplaced: "Spotify"
21-
}
16+
switch self {
17+
case .genius:
18+
return "Genius"
19+
case .lrclib:
20+
return "LRCLIB"
21+
case .musixmatch:
22+
return "Musixmatch"
23+
case .petit:
24+
return "PetitLyrics"
25+
case .notReplaced:
26+
return "Spotify"
2227
}
28+
}
29+
2330

2431
var isReplacingLyrics: Bool { self != .notReplaced }
2532

0 commit comments

Comments
 (0)