mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Merge pull request #6335 from Bnyro/master
fix: crash when search view destroyed before suggestions fetched
This commit is contained in:
commit
459b5df474
@ -92,14 +92,18 @@ class SearchSuggestionsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showHistory() {
|
private fun showHistory() {
|
||||||
|
val searchView = runCatching {
|
||||||
|
(activity as MainActivity).searchView
|
||||||
|
}.getOrNull()
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val historyList = withContext(Dispatchers.IO) {
|
val historyList = withContext(Dispatchers.IO) {
|
||||||
Database.searchHistoryDao().getAll().map { it.query }
|
Database.searchHistoryDao().getAll().map { it.query }
|
||||||
}
|
}
|
||||||
if (historyList.isNotEmpty()) {
|
if (historyList.isNotEmpty() && searchView != null) {
|
||||||
binding.suggestionsRecycler.adapter = SearchHistoryAdapter(
|
binding.suggestionsRecycler.adapter = SearchHistoryAdapter(
|
||||||
historyList,
|
historyList,
|
||||||
(activity as MainActivity).searchView
|
searchView
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
binding.suggestionsRecycler.isGone = true
|
binding.suggestionsRecycler.isGone = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user