fix(search): keep PROCESS_TEXT on the results screen
handleExternalSearch auto-opened the article on an exact match, so the main screen with the search bar flashed before the article covered it. Only set the query; the article now opens from the results list.
This commit is contained in:
1 parent
87dccb4993
commit
0c4ab6dad5
2 files changed
+1
-11
No files matched your search
@@ -144,7 +144,7 @@ class MainActivity : ComponentActivity() {
|
||||
val text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT)
|
||||
?: intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT_READONLY)
|
||||
text?.toString()?.let {
|
||||
searchViewModel.onAction(SearchAction.HandleExternalSearch(it))
|
||||
searchViewModel.onAction(SearchAction.QueryChanged(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ sealed interface SearchAction {
|
||||
data class ArticleClicked(val entry: IndexEntry) : SearchAction
|
||||
data object ClearArticle : SearchAction
|
||||
data class SearchAndLoadArticle(val word: String) : SearchAction
|
||||
data class HandleExternalSearch(val text: String) : SearchAction
|
||||
}
|
||||
|
||||
class SearchViewModel(
|
||||
@@ -140,7 +139,6 @@ class SearchViewModel(
|
||||
}
|
||||
SearchAction.ClearArticle -> clearArticle()
|
||||
is SearchAction.SearchAndLoadArticle -> searchAndLoadArticle(action.word)
|
||||
is SearchAction.HandleExternalSearch -> handleExternalSearch(action.text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,14 +319,6 @@ class SearchViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun handleExternalSearch(text: String) {
|
||||
viewModelScope.launch {
|
||||
val sanitizedText = text.sanitizeQuery()
|
||||
mutableSearchQuery.value = sanitizedText
|
||||
searchAndLoadArticle(sanitizedText)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "SearchViewModel"
|
||||
|
||||
|
||||
Reference in new issue
Block a user