mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Adjust manga FAB to only say "Start" if there's no unread chapters in unfiltered list
Closes #9479
This commit is contained in:
parent
53c6230afe
commit
cf3f2d0380
2 changed files with 10 additions and 9 deletions
|
@ -258,7 +258,7 @@ private fun MangaScreenSmallImpl(
|
||||||
) {
|
) {
|
||||||
val chapterListState = rememberLazyListState()
|
val chapterListState = rememberLazyListState()
|
||||||
|
|
||||||
val chapters = remember(state) { state.processedChapters.toList() }
|
val chapters = remember(state) { state.processedChapters }
|
||||||
|
|
||||||
val internalOnBackPressed = {
|
val internalOnBackPressed = {
|
||||||
if (chapters.fastAny { it.selected }) {
|
if (chapters.fastAny { it.selected }) {
|
||||||
|
@ -320,7 +320,7 @@ private fun MangaScreenSmallImpl(
|
||||||
) {
|
) {
|
||||||
ExtendedFloatingActionButton(
|
ExtendedFloatingActionButton(
|
||||||
text = {
|
text = {
|
||||||
val id = if (chapters.fastAny { it.chapter.read }) {
|
val id = if (state.chapters.fastAny { it.chapter.read }) {
|
||||||
R.string.action_resume
|
R.string.action_resume
|
||||||
} else {
|
} else {
|
||||||
R.string.action_start
|
R.string.action_start
|
||||||
|
@ -485,7 +485,7 @@ fun MangaScreenLargeImpl(
|
||||||
val layoutDirection = LocalLayoutDirection.current
|
val layoutDirection = LocalLayoutDirection.current
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
|
|
||||||
val chapters = remember(state) { state.processedChapters.toList() }
|
val chapters = remember(state) { state.processedChapters }
|
||||||
|
|
||||||
val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
|
val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
|
||||||
var topBarHeight by remember { mutableIntStateOf(0) }
|
var topBarHeight by remember { mutableIntStateOf(0) }
|
||||||
|
@ -555,7 +555,7 @@ fun MangaScreenLargeImpl(
|
||||||
) {
|
) {
|
||||||
ExtendedFloatingActionButton(
|
ExtendedFloatingActionButton(
|
||||||
text = {
|
text = {
|
||||||
val id = if (chapters.fastAny { it.chapter.read }) {
|
val id = if (state.chapters.fastAny { it.chapter.read }) {
|
||||||
R.string.action_resume
|
R.string.action_resume
|
||||||
} else {
|
} else {
|
||||||
R.string.action_start
|
R.string.action_start
|
||||||
|
|
|
@ -119,7 +119,7 @@ class MangaInfoScreenModel(
|
||||||
private val allChapters: List<ChapterItem>?
|
private val allChapters: List<ChapterItem>?
|
||||||
get() = successState?.chapters
|
get() = successState?.chapters
|
||||||
|
|
||||||
private val filteredChapters: Sequence<ChapterItem>?
|
private val filteredChapters: List<ChapterItem>?
|
||||||
get() = successState?.processedChapters
|
get() = successState?.processedChapters
|
||||||
|
|
||||||
val chapterSwipeEndAction = libraryPreferences.swipeEndAction().get()
|
val chapterSwipeEndAction = libraryPreferences.swipeEndAction().get()
|
||||||
|
@ -576,7 +576,7 @@ class MangaInfoScreenModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getUnreadChapters(): List<Chapter> {
|
private fun getUnreadChapters(): List<Chapter> {
|
||||||
val chapterItems = if (skipFiltered) filteredChapters.orEmpty().toList() else allChapters.orEmpty()
|
val chapterItems = if (skipFiltered) filteredChapters.orEmpty() else allChapters.orEmpty()
|
||||||
return chapterItems
|
return chapterItems
|
||||||
.filter { (chapter, dlStatus) -> !chapter.read && dlStatus == Download.State.NOT_DOWNLOADED }
|
.filter { (chapter, dlStatus) -> !chapter.read && dlStatus == Download.State.NOT_DOWNLOADED }
|
||||||
.map { it.chapter }
|
.map { it.chapter }
|
||||||
|
@ -664,7 +664,7 @@ class MangaInfoScreenModel(
|
||||||
|
|
||||||
fun markPreviousChapterRead(pointer: Chapter) {
|
fun markPreviousChapterRead(pointer: Chapter) {
|
||||||
val successState = successState ?: return
|
val successState = successState ?: return
|
||||||
val chapters = filteredChapters.orEmpty().map { it.chapter }.toList()
|
val chapters = filteredChapters.orEmpty().map { it.chapter }
|
||||||
val prevChapters = if (successState.manga.sortDescending()) chapters.asReversed() else chapters
|
val prevChapters = if (successState.manga.sortDescending()) chapters.asReversed() else chapters
|
||||||
val pointerPos = prevChapters.indexOf(pointer)
|
val pointerPos = prevChapters.indexOf(pointer)
|
||||||
if (pointerPos != -1) markChaptersRead(prevChapters.take(pointerPos), true)
|
if (pointerPos != -1) markChaptersRead(prevChapters.take(pointerPos), true)
|
||||||
|
@ -987,8 +987,9 @@ sealed class MangaScreenState {
|
||||||
val hasPromptedToAddBefore: Boolean = false,
|
val hasPromptedToAddBefore: Boolean = false,
|
||||||
) : MangaScreenState() {
|
) : MangaScreenState() {
|
||||||
|
|
||||||
val processedChapters: Sequence<ChapterItem>
|
val processedChapters by lazy {
|
||||||
get() = chapters.applyFilters(manga)
|
chapters.applyFilters(manga).toList()
|
||||||
|
}
|
||||||
|
|
||||||
val trackingAvailable: Boolean
|
val trackingAvailable: Boolean
|
||||||
get() = trackItems.isNotEmpty()
|
get() = trackItems.isNotEmpty()
|
||||||
|
|
Loading…
Reference in a new issue