mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +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() {
|
||||
val searchView = runCatching {
|
||||
(activity as MainActivity).searchView
|
||||
}.getOrNull()
|
||||
|
||||
lifecycleScope.launch {
|
||||
val historyList = withContext(Dispatchers.IO) {
|
||||
Database.searchHistoryDao().getAll().map { it.query }
|
||||
}
|
||||
if (historyList.isNotEmpty()) {
|
||||
if (historyList.isNotEmpty() && searchView != null) {
|
||||
binding.suggestionsRecycler.adapter = SearchHistoryAdapter(
|
||||
historyList,
|
||||
(activity as MainActivity).searchView
|
||||
searchView
|
||||
)
|
||||
} else {
|
||||
binding.suggestionsRecycler.isGone = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user