For #13522: Also remove history entries from tab history. (#17392)

* For #13522: Also remove history entries from tab history.

* For #13522: Test that deleting history also removes it from tab history.
upstream-sync
Mihai Adrian Carare 3 years ago committed by GitHub
parent fc964862e0
commit 3bb074b133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,7 +26,9 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch
import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.RecentlyClosedAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.prompt.ShareData
import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.service.fxa.sync.SyncReason
@ -94,7 +96,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
::deleteHistoryItems,
::syncHistory,
requireComponents.analytics.metrics
)
)
historyInteractor = HistoryInteractor(
historyController
)
@ -271,6 +273,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
requireComponents.analytics.metrics.track(Event.HistoryAllItemsRemoved)
requireComponents.core.store.dispatch(RecentlyClosedAction.RemoveAllClosedTabAction)
requireComponents.core.historyStorage.deleteEverything()
deleteOpenTabsEngineHistory(requireComponents.core.store)
launch(Main) {
viewModel.invalidate()
historyStore.dispatch(HistoryFragmentAction.ExitDeletionMode)
@ -288,6 +291,10 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
}
}
private suspend fun deleteOpenTabsEngineHistory(store: BrowserStore) {
store.dispatch(EngineAction.PurgeHistoryAction).join()
}
private fun share(data: List<ShareData>) {
requireComponents.analytics.metrics.track(Event.HistoryItemShared)
val directions = HistoryFragmentDirections.actionGlobalShareFragment(

@ -7,6 +7,7 @@ package org.mozilla.fenix.settings.deletebrowsingdata
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import mozilla.components.browser.icons.BrowserIcons
import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.RecentlyClosedAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.Engine
@ -43,6 +44,7 @@ class DefaultDeleteBrowsingDataController(
withContext(coroutineContext) {
engine.clearData(Engine.BrowsingData.select(Engine.BrowsingData.DOM_STORAGES))
historyStorage.deleteEverything()
store.dispatch(EngineAction.PurgeHistoryAction)
iconsStorage.clear()
store.dispatch(RecentlyClosedAction.RemoveAllClosedTabAction)
}

@ -13,6 +13,7 @@ import kotlinx.coroutines.GlobalScope.coroutineContext
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.runBlockingTest
import mozilla.components.browser.icons.BrowserIcons
import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.RecentlyClosedAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.Engine
@ -77,6 +78,7 @@ class DefaultDeleteBrowsingDataControllerTest {
coVerify {
engine.clearData(Engine.BrowsingData.select(Engine.BrowsingData.DOM_STORAGES))
historyStorage.deleteEverything()
store.dispatch(EngineAction.PurgeHistoryAction)
store.dispatch(RecentlyClosedAction.RemoveAllClosedTabAction)
iconsStorage.clear()
}

Loading…
Cancel
Save