From 300660492271752a3f75da4f158bd9b8e049a45b Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Wed, 22 Nov 2023 09:08:41 +0600 Subject: [PATCH] MangaScreen: Fix close in action mode exists from screen (#10160) * MangaScreen: Fix close in action mode exists from screen * L --- .../kanade/presentation/manga/MangaScreen.kt | 26 +++++++++---------- .../tachiyomi/ui/manga/MangaScreenModel.kt | 5 ++++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index f5009e962..c8db0c304 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -266,13 +266,12 @@ private fun MangaScreenSmallImpl( ) { val chapterListState = rememberLazyListState() - val chapters = remember(state) { state.processedChapters } - val listItem = remember(state) { state.chapterListItems } - - val isAnySelected by remember { - derivedStateOf { - chapters.fastAny { it.selected } - } + val (chapters, listItem, isAnySelected) = remember(state) { + Triple( + first = state.processedChapters, + second = state.chapterListItems, + third = state.isAnySelected, + ) } val internalOnBackPressed = { @@ -520,13 +519,12 @@ fun MangaScreenLargeImpl( val layoutDirection = LocalLayoutDirection.current val density = LocalDensity.current - val chapters = remember(state) { state.processedChapters } - val listItem = remember(state) { state.chapterListItems } - - val isAnySelected by remember { - derivedStateOf { - chapters.fastAny { it.selected } - } + val (chapters, listItem, isAnySelected) = remember(state) { + Triple( + first = state.processedChapters, + second = state.chapterListItems, + third = state.isAnySelected, + ) } val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt index e49394b0f..73c64e12b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt @@ -6,6 +6,7 @@ import androidx.compose.material3.SnackbarResult import androidx.compose.runtime.Immutable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.util.fastAny import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.screenModelScope import eu.kanade.core.preference.asState @@ -1052,6 +1053,10 @@ class MangaScreenModel( chapters.applyFilters(manga).toList() } + val isAnySelected by lazy { + chapters.fastAny { it.selected } + } + val chapterListItems by lazy { processedChapters.insertSeparators { before, after -> val (lowerChapter, higherChapter) = if (manga.sortDescending()) {