remove spotify as lyrics source

In order to stay on f-droid spotify has to be removed. Doing different flavors is not worth it in my opinion.
This commit is contained in:
2024-07-12 02:15:33 +02:00
committed by Illusion
parent 841629c6e3
commit 7d07433e95
16 changed files with 32 additions and 384 deletions
@@ -22,7 +22,6 @@ data class LyricsState(
val artist: String = "",
val url: Uri = Uri.EMPTY,
val trackId: String = "",
val useSpotifyApi: Boolean = false,
// set by Lyrics screen
val lyrics: String = "",
@@ -35,24 +34,9 @@ class LyricsViewModel(private val lyricsRepository: LyricsRepository): ViewModel
private val _uiState = MutableStateFlow(LyricsState())
val uiState = _uiState.asStateFlow()
fun onSongChange(trackId: String, title: String, subtitle: String, url: Uri, useSpotifyApi: Boolean) {
fun onSongChange(trackId: String, title: String, subtitle: String, url: Uri) {
_uiState.update {
it.copy(song = title, artist = subtitle, url = url, useSpotifyApi = useSpotifyApi, trackId = trackId)
}
}
fun fetchLyricsFromSpotify() {
_uiState.value = _uiState.value.copy(isLoading = true, lyrics = "")
viewModelScope.launch {
withContext(Dispatchers.IO) {
val (lyrics, isSuccess) = lyricsRepository.fetchLyricsFromSpotify(uiState.value.trackId)
if (isSuccess) {
_uiState.value = _uiState.value.copy(isLoading = false, lyrics = lyrics)
} else {
_uiState.value = _uiState.value.copy(isLoading = false, error = lyrics, lyrics = "")
}
}
it.copy(song = title, artist = subtitle, url = url, trackId = trackId)
}
}