From 37e19edf8a5f6a15a95f160390cbcf22d8133380 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 (#2043) Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- 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 6a428506f..edda0f2d7 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -73,10 +73,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) { persistentListOf( EmptyScreenAction( @@ -109,13 +117,6 @@ fun BrowseSourceContent( return } - if (mangaList.itemCount == 0 && mangaList.loadState.refresh is LoadState.Loading) { - LoadingScreen( - modifier = Modifier.padding(contentPadding), - ) - return - } - when (displayMode) { LibraryDisplayMode.ComfortableGrid -> { BrowseSourceComfortableGrid(