fix(search): avoid restarting completed search

This commit is contained in:
HapeLee
2026-07-01 23:43:15 +08:00
parent da00f712bf
commit b657e38712
@@ -542,6 +542,7 @@ class SearchViewModel(
} catch (exception: CancellationException) { } catch (exception: CancellationException) {
throw exception throw exception
} catch (exception: Throwable) { } catch (exception: Throwable) {
wasSearching = false
_uiState.update { it.copy(isSearching = false) } _uiState.update { it.copy(isSearching = false) }
exception.localizedMessage exception.localizedMessage
?.takeIf { it.isNotBlank() } ?.takeIf { it.isNotBlank() }
@@ -571,6 +572,7 @@ class SearchViewModel(
} }
is SearchRunEvent.Finished -> { is SearchRunEvent.Finished -> {
wasSearching = false
_uiState.update { state -> _uiState.update { state ->
val emptyAction = if (searchResultBooks.isEmpty() && event.isEmpty && !searchScope.isAll()) { val emptyAction = if (searchResultBooks.isEmpty() && event.isEmpty && !searchScope.isAll()) {
SearchEmptyScopeAction( SearchEmptyScopeAction(