diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaPresenter.kt index 97bab21a2c..156bb5cd5f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaPresenter.kt @@ -27,10 +27,10 @@ class MigrationMangaPresenter( getFavoritesBySourceId .subscribe(sourceId) .catch { exception -> - _state.emit(MigrateMangaState.Error(exception)) + _state.value = MigrateMangaState.Error(exception) } .collectLatest { list -> - _state.emit(MigrateMangaState.Success(list)) + _state.value = MigrateMangaState.Success(list) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt index 37a2c10695..019d318170 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt @@ -28,10 +28,10 @@ class MigrationSourcesPresenter( presenterScope.launchIO { getSourcesWithFavoriteCount.subscribe() .catch { exception -> - _state.emit(MigrateSourceState.Error(exception)) + _state.value = MigrateSourceState.Error(exception) } .collectLatest { sources -> - _state.emit(MigrateSourceState.Success(sources)) + _state.value = MigrateSourceState.Success(sources) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterPresenter.kt index dd94b3d9d8..d57048c6d7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterPresenter.kt @@ -31,11 +31,11 @@ class SourceFilterPresenter( presenterScope.launchIO { getLanguagesWithSources.subscribe() .catch { exception -> - _state.emit(SourceFilterState.Error(exception)) + _state.value = SourceFilterState.Error(exception) } .collectLatest { sourceLangMap -> val uiModels = sourceLangMap.toFilterUiModels() - _state.emit(SourceFilterState.Success(uiModels)) + _state.value = SourceFilterState.Success(uiModels) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt index ee0ea1a084..3f30be1f9a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt @@ -36,7 +36,7 @@ class SourcePresenter( presenterScope.launchIO { getEnabledSources.subscribe() .catch { exception -> - _state.emit(SourceState.Error(exception)) + _state.value = SourceState.Error(exception) } .collectLatest(::collectLatestSources) } @@ -71,7 +71,7 @@ class SourcePresenter( }.toTypedArray(), ) } - _state.emit(SourceState.Success(uiModels)) + _state.value = SourceState.Success(uiModels) } fun toggleSource(source: Source) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MorePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MorePresenter.kt index 9ceef98567..74840fb8ee 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MorePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MorePresenter.kt @@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.util.lang.launchIO import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers @@ -24,7 +25,7 @@ class MorePresenter( val incognitoMode = preferencesHelper.incognitoMode().asState() private var _state: MutableStateFlow = MutableStateFlow(DownloadQueueState.Stopped) - val downloadQueueState: StateFlow = _state + val downloadQueueState: StateFlow = _state.asStateFlow() private var isDownloading: Boolean = false private var downloadQueueSize: Int = 0 @@ -66,14 +67,12 @@ class MorePresenter( private fun updateDownloadQueueState() { presenterScope.launchIO { val pendingDownloadExists = downloadQueueSize != 0 - _state.emit( - when { - !pendingDownloadExists -> DownloadQueueState.Stopped - !isDownloading && !pendingDownloadExists -> DownloadQueueState.Paused(0) - !isDownloading && pendingDownloadExists -> DownloadQueueState.Paused(downloadQueueSize) - else -> DownloadQueueState.Downloading(downloadQueueSize) - } - ) + _state.value = when { + !pendingDownloadExists -> DownloadQueueState.Stopped + !isDownloading && !pendingDownloadExists -> DownloadQueueState.Paused(0) + !isDownloading && pendingDownloadExists -> DownloadQueueState.Paused(downloadQueueSize) + else -> DownloadQueueState.Downloading(downloadQueueSize) + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt index a04abbe6e2..75306324df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt @@ -53,14 +53,14 @@ class HistoryPresenter( _query.collectLatest { query -> getHistory.subscribe(query) .catch { exception -> - _state.emit(HistoryState.Error(exception)) + _state.value = HistoryState.Error(exception) } .map { pagingData -> pagingData.toHistoryUiModels() } .cachedIn(presenterScope) .let { uiModelsPagingDataFlow -> - _state.emit(HistoryState.Success(uiModelsPagingDataFlow)) + _state.value = HistoryState.Success(uiModelsPagingDataFlow) } } }