Przeglądaj źródła

fix: 正文搜素关键词残留

HapeLee 4 miesięcy temu
rodzic
commit
c677ce5660

+ 8 - 0
app/src/main/java/io/legado/app/data/repository/SearchContentRepository.kt

@@ -44,6 +44,14 @@ class SearchContentRepository {
         cacheResults(bookUrl, query, replaceEnabled, regexReplace, emptyList())
     }
 
+    fun clearSession(bookUrl: String) {
+        if (lastSearchSession?.bookUrl == bookUrl) {
+            lastSearchResults = null
+            lastQueryKey = null
+            lastSearchSession = null
+        }
+    }
+
     fun getCache(
         bookUrl: String,
         query: String,

+ 1 - 0
app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt

@@ -134,6 +134,7 @@ class SearchContentViewModel(
         val regex = _regexReplace.value
 
         if (query.isBlank()) {
+            searchContentRepository.clearSession(bookUrl)
             _uiState.update {
                 it.copy(
                     isSearching = false,