Skip to content

Commit

Permalink
Fix add-on search
Browse files Browse the repository at this point in the history
  • Loading branch information
interfect committed Mar 5, 2021
1 parent 1da7a9f commit dd6e3dd
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
*/
private var isInstallationInProgress = false
private var adapter: PagedAddonsManagerAdapter? = null
// We must save the add-on list in the class, or we won't have it
// downloaded for the non-suspending search function
private var addons: List<Addon>? = null

override fun onCreateView(
Expand Down Expand Up @@ -176,14 +178,14 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
val allowCache = args.installAddonId == null || installExternalAddonComplete
lifecycleScope.launch(IO) {
try {
val addons = requireContext().components.addonManager.getAddons(allowCache = allowCache)
addons = requireContext().components.addonManager.getAddons(allowCache = allowCache)
lifecycleScope.launch(Dispatchers.Main) {
runIfFragmentIsAttached {
if (!shouldRefresh) {
adapter = PagedAddonsManagerAdapter(
requireContext().components.addonCollectionProvider,
managementView,
addons,
addons!!,
style = createAddonStyle(requireContext())
)
}
Expand All @@ -193,12 +195,12 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)

recyclerView.adapter = adapter
if (shouldRefresh) {
adapter?.updateAddons(addons)
adapter?.updateAddons(addons!!)
}

args.installAddonId?.let { addonIn ->
if (!installExternalAddonComplete) {
installExternalAddon(addons, addonIn)
installExternalAddon(addons!!, addonIn)
}
}
}
Expand Down

0 comments on commit dd6e3dd

Please sign in to comment.