For issue #9493: Reload after cleaning individual site permissions exceptions
parent
6f5f48c30e
commit
956bf01cd5
|
@ -0,0 +1,17 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.settings.sitepermissions
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import org.mozilla.fenix.components.Components
|
||||
|
||||
/**
|
||||
* Try to reload a session if a session with the given [origin] it is found.
|
||||
* @param origin The origin the session to be reloaded.
|
||||
*/
|
||||
internal fun Components.tryReloadTabBy(origin: String) {
|
||||
val session = core.sessionManager.all.find { it.url.toUri().host == origin }
|
||||
useCases.sessionUseCases.reload(session)
|
||||
}
|
|
@ -100,6 +100,7 @@ class SitePermissionsDetailsExceptionsFragment : PreferenceFragmentCompat() {
|
|||
requireContext().components.core.permissionStorage.deleteSitePermissions(sitePermissions)
|
||||
withContext(Main) {
|
||||
requireView().findNavController().popBackStack()
|
||||
requireContext().components.tryReloadTabBy(sitePermissions.origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
||||
import mozilla.components.feature.sitepermissions.SitePermissions.Status.ALLOWED
|
||||
|
@ -165,6 +166,9 @@ class SitePermissionsManageExceptionsPhoneFeatureFragment : Fragment() {
|
|||
}
|
||||
viewLifecycleOwner.lifecycleScope.launch(IO) {
|
||||
requireComponents.core.permissionStorage.updateSitePermissions(updatedSitePermissions)
|
||||
launch(Main) {
|
||||
requireComponents.tryReloadTabBy(updatedSitePermissions.origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue