Skip to content

Commit

Permalink
fix: force close when navigating back from search
Browse files Browse the repository at this point in the history
  • Loading branch information
uragiristereo committed May 14, 2022
1 parent 162d914 commit 8fe64da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ fun SearchScreen(
onDispose { }
}

DisposableEffect(key1 = viewModel) {
onDispose {
viewModel.cancelSearch()
}
}

DisposableEffect(key1 = query.text) {
if (query.text.isEmpty()) {
viewModel.clearSearches()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ class SearchViewModel @Inject constructor(
parsedQuery = SearchUtil.parseSearchQuery(query = query),
)
}

fun cancelSearch() {
job?.cancel()
}
}

0 comments on commit 8fe64da

Please sign in to comment.