|
|
|
@ -80,6 +80,7 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|
|
|
|
|
|
|
|
|
private var homeMenu: HomeMenu? = null
|
|
|
|
|
|
|
|
|
|
var deleteAllSessionsJob: (suspend () -> Unit)? = null
|
|
|
|
|
var deleteSessionJob: (suspend () -> Unit)? = null
|
|
|
|
|
var deleteCollectionJob: (suspend () -> Unit)? = null
|
|
|
|
|
|
|
|
|
@ -299,7 +300,7 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
is TabAction.CloseAll -> {
|
|
|
|
|
requireComponents.useCases.tabsUseCases.removeAllTabsOfType.invoke(action.private)
|
|
|
|
|
removeAllTabsWithUndo(action.private)
|
|
|
|
|
}
|
|
|
|
|
is TabAction.PrivateBrowsingLearnMore -> {
|
|
|
|
|
(activity as HomeActivity).openToBrowserAndLoad(
|
|
|
|
@ -333,6 +334,14 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteAllSessionsJob?.let {
|
|
|
|
|
launch {
|
|
|
|
|
it.invoke()
|
|
|
|
|
}.invokeOnCompletion {
|
|
|
|
|
deleteAllSessionsJob = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCollectionJob?.let {
|
|
|
|
|
launch {
|
|
|
|
|
it.invoke()
|
|
|
|
@ -493,6 +502,23 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|
|
|
|
return observer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun removeAllTabsWithUndo(isPrivate: Boolean) {
|
|
|
|
|
getManagedEmitter<SessionControlChange>().onNext(SessionControlChange.TabsChange(listOf()))
|
|
|
|
|
deleteAllSessionsJob = {
|
|
|
|
|
requireComponents.useCases.tabsUseCases.removeAllTabsOfType.invoke(isPrivate)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CoroutineScope(Dispatchers.Main).allowUndo(
|
|
|
|
|
view!!, getString(R.string.snackbar_tabs_deleted),
|
|
|
|
|
getString(R.string.snackbar_deleted_undo), {
|
|
|
|
|
deleteAllSessionsJob = null
|
|
|
|
|
emitSessionChanges()
|
|
|
|
|
}
|
|
|
|
|
) {
|
|
|
|
|
requireComponents.useCases.tabsUseCases.removeAllTabsOfType.invoke(isPrivate)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun removeTabWithUndo(sessionId: String) {
|
|
|
|
|
val sessionManager = requireComponents.core.sessionManager
|
|
|
|
|
|
|
|
|
|