diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapter.kt b/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapter.kt index 53e21323ef..602a73281b 100644 --- a/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapter.kt +++ b/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapter.kt @@ -21,8 +21,8 @@ class GetNextChapter( } suspend fun await(mangaId: Long, chapterId: Long): Chapter? { - val chapter = getChapter.await(chapterId)!! - val manga = getManga.await(mangaId)!! + val chapter = getChapter.await(chapterId) ?: return null + val manga = getManga.await(mangaId) ?: return null if (!chapter.read) return chapter diff --git a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt index 9760c8e369..1f249465cb 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -89,7 +89,7 @@ fun BrowseSourceScreen( Column(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) { BrowseSourceToolbar( state = presenter, - source = presenter.source!!, + source = presenter.source, displayMode = presenter.displayMode, onDisplayModeChange = { presenter.displayMode = it }, navigateUp = navigateUp, diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt index efbd4e79f2..3266ac8f26 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt @@ -33,7 +33,7 @@ import eu.kanade.tachiyomi.source.LocalSource @Composable fun BrowseSourceToolbar( state: BrowseSourceState, - source: CatalogueSource, + source: CatalogueSource?, displayMode: LibraryDisplayMode, onDisplayModeChange: (LibraryDisplayMode) -> Unit, navigateUp: () -> Unit, @@ -44,7 +44,7 @@ fun BrowseSourceToolbar( ) { if (state.searchQuery == null) { BrowseSourceRegularToolbar( - title = if (state.isUserQuery) state.currentFilter.query else source.name, + title = if (state.isUserQuery) state.currentFilter.query else source?.name.orEmpty(), isLocalSource = source is LocalSource, displayMode = displayMode, onDisplayModeChange = onDisplayModeChange, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterPresenter.kt index 41f132a29d..3328ec0625 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterPresenter.kt @@ -13,6 +13,7 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow +import kotlinx.coroutines.flow.stateIn import logcat.LogPriority import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -35,6 +36,7 @@ class ExtensionFilterPresenter( logcat(LogPriority.ERROR, exception) _events.send(Event.FailedFetchingLanguages) } + .stateIn(presenterScope) .collectLatest(::collectLatestSourceLangMap) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt index 54c824eff3..cc5854ba75 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt @@ -29,10 +29,6 @@ class SourceSearchController( @Composable override fun ComposeContent() { - // LocalContext is not a first available to us when we try access it - // Decoupling from BrowseSourceController is needed - val context = applicationContext!! - SourceSearchScreen( presenter = presenter, navigateUp = { router.popCurrentController() }, @@ -46,8 +42,10 @@ class SourceSearchController( }, onWebViewClick = f@{ val source = presenter.source as? HttpSource ?: return@f - val intent = WebViewActivity.newIntent(context, source.baseUrl, source.id, source.name) - context.startActivity(intent) + activity?.let { context -> + val intent = WebViewActivity.newIntent(context, source.baseUrl, source.id, source.name) + context.startActivity(intent) + } }, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterPresenter.kt index 5cf6e4a5a5..c80d331d91 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterPresenter.kt @@ -15,6 +15,7 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow +import kotlinx.coroutines.flow.stateIn import logcat.LogPriority import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -39,6 +40,7 @@ class SourcesFilterPresenter( logcat(LogPriority.ERROR, exception) _events.send(Event.FailedFetchingLanguages) } + .stateIn(presenterScope) .collectLatest(::collectLatestSourceLangMap) } }