Don't show load state indicator when no hits found

This commit is contained in:
FooIbar committed 2024-08-18 17:40:48 +08:00
1 parent 1883b82159
commit 5aeded7a24
4 files changed
+16 -4

No files matched your search

@@ -29,6 +29,7 @@ import com.hippo.ehviewer.client.data.FavListUrlBuilder
import com.hippo.ehviewer.client.data.GalleryInfo
import com.hippo.ehviewer.client.exception.EhException
import com.hippo.ehviewer.client.exception.InsufficientFundsException
import com.hippo.ehviewer.client.exception.NoHitsFoundException
import com.hippo.ehviewer.client.exception.NotLoggedInException
import com.hippo.ehviewer.client.exception.ParseException
import com.hippo.ehviewer.client.parser.ArchiveParser
@@ -130,7 +131,7 @@ fun rethrowExactly(status: HttpStatusCode, body: Either<String, ByteBuffer>, e:
if (e is ParseException || e is SerializationException) {
body.onLeft { if ("<" !in it) throw EhException(it) }
when (val message = e.cause?.message) {
"No hits found!" -> throw EhException(R.string.gallery_list_empty_hit)
"No hits found!" -> throw NoHitsFoundException()
"No watched tags!" -> throw EhException(R.string.gallery_list_empty_hit_subscription)
"Not logged in!" -> throw NotLoggedInException()
is String -> if (message.startsWith("Your IP address")) throw EhException(message)
@@ -0,0 +1,5 @@
package com.hippo.ehviewer.client.exception
import com.hippo.ehviewer.R
class NoHitsFoundException : EhException(R.string.gallery_list_empty_hit)
@@ -53,6 +53,7 @@ import androidx.paging.compose.itemKey
import com.hippo.ehviewer.R
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.client.data.BaseGalleryInfo
import com.hippo.ehviewer.client.exception.NoHitsFoundException
import com.hippo.ehviewer.collectAsState
import com.hippo.ehviewer.icons.EhIcons
import com.hippo.ehviewer.icons.big.SadAndroid
@@ -116,6 +117,11 @@ fun GalleryList(
}
},
) {
val showLoadStateIndicator = when (val state = data.loadState.append) {
LoadState.Loading -> true
is LoadState.Error -> state.error !is NoHitsFoundException
is LoadState.NotLoading -> false
}
if (listMode == 0) {
val columnWidth by collectDetailSizeAsState()
FastScrollLazyVerticalGrid(
@@ -136,7 +142,7 @@ fun GalleryList(
detailItemContent(info)
}
}
if (data.loadState.append !is LoadState.NotLoading) {
if (showLoadStateIndicator) {
item(span = { GridItemSpan(maxLineSpan) }) {
LoadStateIndicator(state = data.loadState.append) {
data.retry()
@@ -165,7 +171,7 @@ fun GalleryList(
thumbItemContent(info)
}
}
if (data.loadState.append !is LoadState.NotLoading) {
if (showLoadStateIndicator) {
item(span = StaggeredGridItemSpan.FullLine) {
LoadStateIndicator(state = data.loadState.append) {
data.retry()
+1 -1
View File
@@ -201,7 +201,7 @@ pub fn parse_info_list(dom: &VDom, parser: &Parser, str: &str) -> Result<Gallery
if str.contains("<p>You do not have any watched tags") {
bail!("No watched tags!")
}
if str.contains("No hits found</p>") || str.contains("No unfiltered results found") {
if str.contains("No hits found</p>") || str.contains("No unfiltered results") {
bail!("No hits found!")
}
let f = || {