File tree Expand file tree Collapse file tree
app/src/main/java/de/christinecoenen/code/zapp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
1313import kotlinx.coroutines.flow.first
1414import kotlinx.coroutines.flow.firstOrNull
1515import kotlinx.coroutines.flow.mapLatest
16- import kotlinx.coroutines.flow.onStart
1716
1817@OptIn(ExperimentalCoroutinesApi ::class )
1918class ShowMenuHelperViewModel (
@@ -108,7 +107,10 @@ class ShowMenuHelperViewModel(
108107 }
109108
110109 suspend fun startDownload (show : MediathekShow , quality : Quality ) {
111- val persistedShow = mediathekRepository.getPersistedShowByApiId(show.apiId).first()
110+ val persistedShow = mediathekRepository
111+ .persistOrUpdateShow(show)
112+ .first()
113+
112114 downloadController.startDownload(persistedShow.id, quality)
113115 }
114116}
Original file line number Diff line number Diff line change @@ -153,12 +153,11 @@ class MediathekRepository(private val database: Database) {
153153 .flowOn(Dispatchers .IO )
154154 }
155155
156- fun getPersistedShowByApiId (apiId : String ): Flow <PersistedMediathekShow > {
156+ fun getPersistedShowByApiId (apiId : String ): Flow <PersistedMediathekShow ? > {
157157 return database
158158 .mediathekShowDao()
159159 .getFromApiId(apiId)
160160 .distinctUntilChanged()
161- .filterNotNull()
162161 .flowOn(Dispatchers .IO )
163162 }
164163
You can’t perform that action at this time.
0 commit comments