mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
refactor(core/series): improve data loading reliability with concurrent initialization
This commit is contained in:
@@ -5,9 +5,9 @@ import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import hu.bbara.purefin.core.Offline
|
||||
import hu.bbara.purefin.core.data.LocalMediaRepository
|
||||
import hu.bbara.purefin.core.data.MediaMetadataUpdater
|
||||
import hu.bbara.purefin.core.download.DownloadState
|
||||
import hu.bbara.purefin.core.download.MediaDownloadController
|
||||
import hu.bbara.purefin.core.data.MediaMetadataUpdater
|
||||
import hu.bbara.purefin.core.navigation.EpisodeDto
|
||||
import hu.bbara.purefin.core.navigation.NavigationManager
|
||||
import hu.bbara.purefin.core.navigation.Route
|
||||
@@ -98,12 +98,6 @@ class SeriesViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun loadSeasonEpisodes(seriesId: UUID, seasonId: UUID) {
|
||||
viewModelScope.launch {
|
||||
selectedMediaCatalogReader().loadSeasonEpisodes(seriesId, seasonId)
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadSeason(seriesId: UUID, seasonId: UUID) {
|
||||
viewModelScope.launch {
|
||||
val mediaCatalogReader = selectedMediaCatalogReader()
|
||||
@@ -196,8 +190,14 @@ class SeriesViewModel @Inject constructor(
|
||||
_series.value = series
|
||||
viewModelScope.launch {
|
||||
val mediaCatalogReader = mediaCatalogReader(series.offline)
|
||||
mediaCatalogReader.loadSeries(series.id)
|
||||
mediaCatalogReader.loadSeasons(series.id)
|
||||
launch { mediaCatalogReader.loadSeries(series.id) }
|
||||
launch { mediaCatalogReader.loadSeasons(series.id) }
|
||||
}
|
||||
}
|
||||
|
||||
fun selectSeason(seriesId: UUID, seasonId: UUID) {
|
||||
viewModelScope.launch {
|
||||
selectedMediaCatalogReader().loadSeasonEpisodes(seriesId, seasonId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user