From 376a13fb1ca3c9bcb68fd0cd947f1f74f30839ff Mon Sep 17 00:00:00 2001 From: NarwhalHorns Date: Sat, 26 Apr 2025 22:36:50 +0100 Subject: [PATCH] Fix empty layout not appearing in browse source screen in some cases (mihonapp/mihon#2043) Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 37e19edf8a5f6a15a95f160390cbcf22d8133380) --- CHANGELOG.md | 1 + .../presentation/browse/BrowseSourceScreen.kt | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67c9cd802..4c69ade9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Fix duplicate requests in WebView due to empty reasonPhrase ([@AwkwardPeak7](https://github.com/AwkwardPeak7)) ([#2003](https://github.com/mihonapp/mihon/pull/2003)) - Fix content under source browse screen top appbar is interactable ([@AntsyLich](https://github.com/AntsyLich)) ([#2026](https://github.com/mihonapp/mihon/pull/2026)) - Fix crash when trying use source sort filter without a pre-selection ([@AntsyLich](https://github.com/AntsyLich)) ([#2036](https://github.com/mihonapp/mihon/pull/2036)) +- Fix empty layout not appearing in browse source screen in some cases ([@NarwhalHorns](https://github.com/NarwhalHorns)) ([#2043](https://github.com/mihonapp/mihon/pull/2043)) ### Removed - Remove Okhttp networking from WebView Screen ([@AwkwardPeak7](https://github.com/AwkwardPeak7)) ([#2020](https://github.com/mihonapp/mihon/pull/2020)) 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 a4fb6daaf..55a0f40fa 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -85,10 +85,18 @@ fun BrowseSourceContent( } } - if (mangaList.itemCount <= 0 && errorState != null && errorState is LoadState.Error) { + if (mangaList.itemCount == 0 && mangaList.loadState.refresh is LoadState.Loading) { + LoadingScreen(Modifier.padding(contentPadding)) + return + } + + if (mangaList.itemCount == 0) { EmptyScreen( modifier = Modifier.padding(contentPadding), - message = getErrorMessage(errorState), + message = when (errorState) { + is LoadState.Error -> getErrorMessage(errorState) + else -> stringResource(MR.strings.no_results_found) + }, actions = if (source is LocalSource /* SY --> */ && onLocalSourceHelpClick != null /* SY <-- */) { persistentListOf( EmptyScreenAction( @@ -131,13 +139,6 @@ fun BrowseSourceContent( return } - if (mangaList.itemCount == 0 && mangaList.loadState.refresh is LoadState.Loading) { - LoadingScreen( - modifier = Modifier.padding(contentPadding), - ) - return - } - // SY --> if (source?.isEhBasedSource() == true && ehentaiBrowseDisplayMode) { BrowseSourceEHentaiList(