diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt index fc093d2..0b0bbc7 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt @@ -81,7 +81,7 @@ class LyricsProviderService { * @return The synced lyrics as a string. */ suspend fun getSyncedLyrics( - songLink: String, + songLink: String?, version: String, provider: Providers, // TODO providers could be a sealed interface to include such parameters @@ -89,7 +89,7 @@ class LyricsProviderService { ): String? { return try { when (provider) { - Providers.SPOTIFY -> SpotifyLyricsAPI().getSyncedLyrics(songLink, version) + Providers.SPOTIFY -> SpotifyLyricsAPI().getSyncedLyrics(songLink!!, version) Providers.LRCLIB -> LRCLibAPI().getSyncedLyrics(lrcLibID) Providers.NETEASE -> NeteaseAPI().getSyncedLyrics( neteaseID, diff --git a/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt b/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt index e822e02..85065a7 100644 --- a/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt +++ b/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt @@ -272,7 +272,7 @@ class HomeViewModel( suspend fun getSongInfo(query: SongInfo): SongInfo? = lyricsProviderService.getSongInfo(query, provider = userSettingsController.selectedProvider) - suspend fun getSyncedLyrics(link: String, version: String): String? = + suspend fun getSyncedLyrics(link: String?, version: String): String? = lyricsProviderService.getSyncedLyrics(link, version, provider = userSettingsController.selectedProvider) fun selectSong(song: Song, newValue: Boolean) { diff --git a/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt b/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt index 5e3e1a6..5a07952 100644 --- a/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt +++ b/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt @@ -42,7 +42,7 @@ class LyricsFetchViewModel( var lyricsFetchState by mutableStateOf(LyricsFetchState.NotSubmitted) - private suspend fun getSyncedLyrics(link: String, version: String): String? = + private suspend fun getSyncedLyrics(link: String?, version: String): String? = lyricsProviderService.getSyncedLyrics( link, version, @@ -106,7 +106,7 @@ class LyricsFetchViewModel( try { val lyrics = getSyncedLyrics( - link = songLink ?: throw IllegalStateException("Attempted lyrics retrieval with empty URL"), + link = songLink, version = context.getVersion() ) ?: throw NullPointerException("Lyrics result is null") diff --git a/app/src/main/java/pl/lambada/songsync/util/LyricsUtils.kt b/app/src/main/java/pl/lambada/songsync/util/LyricsUtils.kt index 27741c6..1092ab1 100644 --- a/app/src/main/java/pl/lambada/songsync/util/LyricsUtils.kt +++ b/app/src/main/java/pl/lambada/songsync/util/LyricsUtils.kt @@ -233,7 +233,7 @@ private suspend fun downloadLyricsForSong( runCatching { viewModel .getSyncedLyrics( - link = songInfo.songLink ?: error("attempted to get lyrics without link"), + link = songInfo.songLink, version = context.getVersion() ) ?: throw NullPointerException("Lyrics result is null")