Fix some crashes
(cherry picked from commit 5efb31bd7105975ef531aaebbb70e3f409378663) # Conflicts: # app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt # app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt
This commit is contained in:
parent
55a07ae51a
commit
38abaa162e
@ -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
|
||||
|
||||
|
@ -94,7 +94,7 @@ fun BrowseSourceScreen(
|
||||
Column(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) {
|
||||
BrowseSourceToolbar(
|
||||
state = presenter,
|
||||
source = presenter.source!!,
|
||||
source = presenter.source,
|
||||
displayMode = presenter.displayMode.takeUnless { presenter.source!!.isEhBasedSource() && presenter.ehentaiBrowseDisplayMode },
|
||||
onDisplayModeChange = { presenter.displayMode = it },
|
||||
navigateUp = navigateUp,
|
||||
|
@ -36,7 +36,7 @@ import exh.source.anyIs
|
||||
@Composable
|
||||
fun BrowseSourceToolbar(
|
||||
state: BrowseSourceState,
|
||||
source: CatalogueSource,
|
||||
source: CatalogueSource?,
|
||||
displayMode: LibraryDisplayMode?,
|
||||
onDisplayModeChange: (LibraryDisplayMode) -> Unit,
|
||||
navigateUp: () -> Unit,
|
||||
@ -50,7 +50,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,
|
||||
// SY -->
|
||||
isConfigurableSource = source.anyIs<ConfigurableSource>(),
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,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() },
|
||||
@ -50,8 +46,10 @@ class SourceSearchController(
|
||||
// SY <--
|
||||
onWebViewClick = f@{
|
||||
val source = presenter.source as? HttpSource ?: return@f
|
||||
activity?.let { context ->
|
||||
val intent = WebViewActivity.newIntent(context, source.baseUrl, source.id, source.name)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -16,6 +16,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
|
||||
@ -43,6 +44,7 @@ class SourcesFilterPresenter(
|
||||
logcat(LogPriority.ERROR, exception)
|
||||
_events.send(Event.FailedFetchingLanguages)
|
||||
}
|
||||
.stateIn(presenterScope)
|
||||
.collectLatest(::collectLatestSourceLangMap)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user