diff --git a/app/src/main/java/exh/recs/RecommendsScreen.kt b/app/src/main/java/exh/recs/RecommendsScreen.kt index 9bed4784f..7523da73a 100644 --- a/app/src/main/java/exh/recs/RecommendsScreen.kt +++ b/app/src/main/java/exh/recs/RecommendsScreen.kt @@ -56,18 +56,37 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen() { // KMK <-- val onClickItem = { manga: Manga -> - navigator.push( - when (manga.source) { - -1L -> SourcesScreen(SourcesScreen.SmartSearchConfig(manga.ogTitle)) - else -> MangaScreen(manga.id, true) - }, - ) + when (manga.source) { + -1L -> navigator.push( + SourcesScreen(SourcesScreen.SmartSearchConfig(manga.ogTitle)), + ) + else -> { + // KMK --> + scope.launchIO { + val localManga = screenModel.networkToLocalManga.getLocal(manga) + navigator.push( + // KMK <-- + MangaScreen(localManga.id, true), + ) + } + } + } } val onLongClickItem = { manga: Manga -> when (manga.source) { -1L -> WebViewActivity.newIntent(context, manga.url, title = manga.title).let(context::startActivity) - else -> onClickItem(manga) + else -> { + // KMK --> + scope.launchIO { + val localManga = screenModel.networkToLocalManga.getLocal(manga) + bulkFavoriteScreenModel.addRemoveManga( + localManga, + haptic, + ) + } + // KMK <-- + } } } @@ -87,33 +106,8 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen() { ), ) }, - onClickItem = { - // KMK --> - scope.launchIO { - val manga = screenModel.networkToLocalManga.getLocal(it) - if (bulkFavoriteState.selectionMode) { - bulkFavoriteScreenModel.toggleSelection(manga) - } else { - // KMK <-- - onClickItem(manga) - } - } - }, - onLongClickItem = { - // KMK --> - scope.launchIO { - val manga = screenModel.networkToLocalManga.getLocal(it) - if (!bulkFavoriteState.selectionMode) { - bulkFavoriteScreenModel.addRemoveManga(manga, haptic) - } else { - // KMK <-- - onLongClickItem(manga) - } - } - }, - // KMK --> - bulkFavoriteScreenModel = bulkFavoriteScreenModel, - // KMK <-- + onClickItem = { onClickItem(it) }, + onLongClickItem = { onLongClickItem(it) }, ) // KMK --> diff --git a/app/src/main/java/exh/recs/RecommendsScreenModel.kt b/app/src/main/java/exh/recs/RecommendsScreenModel.kt index 959e810a6..c0293f02f 100644 --- a/app/src/main/java/exh/recs/RecommendsScreenModel.kt +++ b/app/src/main/java/exh/recs/RecommendsScreenModel.kt @@ -74,13 +74,11 @@ open class RecommendsScreenModel( val titles = page.mangas.map { val recSourceId = recSource.associatedSourceId - if (recSourceId != null) { - // If the recommendation is associated with a source, resolve it - networkToLocalManga.await(it.toDomainManga(recSourceId)) - } else { - // Otherwise, skip this step. The user will be prompted to choose a source via SmartSearch - it.toDomainManga(-1) - } + // KMK --> + // If the recommendation is associated with a source, resolve it + // Otherwise, skip this step. The user will be prompted to choose a source via SmartSearch + it.toDomainManga(recSourceId ?: -1) + // KMK <-- } if (isActive) { diff --git a/app/src/main/java/exh/recs/components/RecommendsScreen.kt b/app/src/main/java/exh/recs/components/RecommendsScreen.kt index 5aa191884..88128dd1e 100644 --- a/app/src/main/java/exh/recs/components/RecommendsScreen.kt +++ b/app/src/main/java/exh/recs/components/RecommendsScreen.kt @@ -4,18 +4,13 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable import androidx.compose.runtime.State -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalContext -import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar import eu.kanade.presentation.browse.components.GlobalSearchCardRow import eu.kanade.presentation.browse.components.GlobalSearchErrorResultItem import eu.kanade.presentation.browse.components.GlobalSearchLoadingResultItem import eu.kanade.presentation.browse.components.GlobalSearchResultItem -import eu.kanade.presentation.components.BulkSelectionToolbar +import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.util.formattedMessage -import eu.kanade.tachiyomi.ui.browse.BulkFavoriteScreenModel -import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SearchItemResult import exh.recs.RecommendationItemResult import exh.recs.RecommendsScreenModel import exh.recs.sources.RecommendationPagingSource @@ -35,52 +30,14 @@ fun RecommendsScreen( onClickSource: (RecommendationPagingSource) -> Unit, onClickItem: (Manga) -> Unit, onLongClickItem: (Manga) -> Unit, - // KMK --> - bulkFavoriteScreenModel: BulkFavoriteScreenModel, - // KMK <-- ) { - // KMK --> - val bulkFavoriteState by bulkFavoriteScreenModel.state.collectAsState() - // KMK <-- - Scaffold( topBar = { scrollBehavior -> - // KMK --> - if (bulkFavoriteState.selectionMode) { - BulkSelectionToolbar( - selectedCount = bulkFavoriteState.selection.size, - isRunning = bulkFavoriteState.isRunning, - onClickClearSelection = bulkFavoriteScreenModel::toggleSelectionMode, - onChangeCategoryClick = bulkFavoriteScreenModel::addFavorite, - onSelectAll = { - state.filteredItems.forEach { (_, result) -> - if (result is RecommendationItemResult.Success) { - result.result.forEach { manga -> - bulkFavoriteScreenModel.select(manga) - } - } - } - }, - onReverseSelection = { - bulkFavoriteScreenModel.reverseSelection( - state.filteredItems.values - .filterIsInstance() - .flatMap { it.result }, - ) - }, - ) - } else { - BrowseSourceSimpleToolbar( - displayMode = null, - onDisplayModeChange = {}, - toggleSelectionMode = bulkFavoriteScreenModel::toggleSelectionMode, - isRunning = bulkFavoriteState.isRunning, - // KMK <-- - title = stringResource(SYMR.strings.similar, manga?.title.orEmpty()), - scrollBehavior = scrollBehavior, - navigateUp = navigateUp, - ) - } + AppBar( + title = stringResource(SYMR.strings.similar, manga?.title.orEmpty()), + scrollBehavior = scrollBehavior, + navigateUp = navigateUp, + ) }, ) { paddingValues -> RecommendsContent( @@ -90,9 +47,6 @@ fun RecommendsScreen( onClickSource = onClickSource, onClickItem = onClickItem, onLongClickItem = onLongClickItem, - // KMK --> - selection = bulkFavoriteState.selection, - // KMK <-- ) } } @@ -105,9 +59,6 @@ internal fun RecommendsContent( onClickSource: (RecommendationPagingSource) -> Unit, onClickItem: (Manga) -> Unit, onLongClickItem: (Manga) -> Unit, - // KMK --> - selection: List, - // KMK <-- ) { LazyColumn( contentPadding = contentPadding, @@ -130,7 +81,7 @@ internal fun RecommendsContent( onClick = onClickItem, onLongClick = onLongClickItem, // KMK --> - selection = selection, + selection = emptyList(), // KMK <-- ) }