mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] Migrate some "selected tab" reads from SessionManager to BrowserStore.
This commit is contained in:
parent
82847b2b61
commit
8a7505843a
@ -22,6 +22,7 @@ import kotlinx.coroutines.launch
|
||||
import mozilla.appservices.Megazord
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.state.action.SystemAction
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.concept.base.crash.Breadcrumb
|
||||
import mozilla.components.concept.push.PushProcessor
|
||||
import mozilla.components.feature.addons.update.GlobalAddonDependencyProvider
|
||||
@ -398,7 +399,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
|
||||
onNewTabOverride = {
|
||||
_, engineSession, url ->
|
||||
val shouldCreatePrivateSession =
|
||||
components.core.sessionManager.selectedSession?.private
|
||||
components.core.store.state.selectedTab?.content?.private
|
||||
?: components.settings.openLinksInAPrivateTab
|
||||
|
||||
val session = Session(url, shouldCreatePrivateSession)
|
||||
|
@ -68,6 +68,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||
contentLayout = browserLayout,
|
||||
tabPreview = tabPreview,
|
||||
toolbarLayout = browserToolbarView.view,
|
||||
store = components.core.store,
|
||||
sessionManager = components.core.sessionManager
|
||||
)
|
||||
)
|
||||
|
@ -19,6 +19,8 @@ import androidx.core.view.isVisible
|
||||
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.support.ktx.android.view.getRectWithViewLocation
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.getRectWithScreenLocation
|
||||
@ -40,6 +42,7 @@ class ToolbarGestureHandler(
|
||||
private val contentLayout: View,
|
||||
private val tabPreview: TabPreview,
|
||||
private val toolbarLayout: View,
|
||||
private val store: BrowserStore,
|
||||
private val sessionManager: SessionManager
|
||||
) : SwipeGestureListener {
|
||||
|
||||
@ -145,15 +148,15 @@ class ToolbarGestureHandler(
|
||||
|
||||
private fun getDestination(): Destination {
|
||||
val isLtr = activity.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
||||
val currentSession = sessionManager.selectedSession ?: return Destination.None
|
||||
val currentIndex = sessionManager.sessionsOfType(currentSession.private).indexOfFirst {
|
||||
it.id == currentSession.id
|
||||
val currentTab = store.state.selectedTab ?: return Destination.None
|
||||
val currentIndex = sessionManager.sessionsOfType(currentTab.content.private).indexOfFirst {
|
||||
it.id == currentTab.id
|
||||
}
|
||||
|
||||
return if (currentIndex == -1) {
|
||||
Destination.None
|
||||
} else {
|
||||
val sessions = sessionManager.sessionsOfType(currentSession.private)
|
||||
val sessions = sessionManager.sessionsOfType(currentTab.content.private)
|
||||
val index = when (gestureDirection) {
|
||||
GestureDirection.RIGHT_TO_LEFT -> if (isLtr) {
|
||||
currentIndex + 1
|
||||
|
@ -77,7 +77,7 @@ class DefaultBrowserToolbarController(
|
||||
store.updateSearchTermsOfSelectedSession(text)
|
||||
activity.components.useCases.searchUseCases.defaultSearch.invoke(
|
||||
text,
|
||||
sessionId = sessionManager.selectedSession?.id
|
||||
sessionId = store.state.selectedTabId
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.component_browser_top_toolbar.view.*
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.browser.state.state.ExternalAppType
|
||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||
import mozilla.components.browser.toolbar.behavior.BrowserToolbarBottomBehavior
|
||||
@ -98,7 +99,6 @@ class BrowserToolbarView(
|
||||
}
|
||||
|
||||
with(container.context) {
|
||||
val sessionManager = components.core.sessionManager
|
||||
val isPinningSupported = components.useCases.webAppUseCases.isPinningSupported()
|
||||
|
||||
if (toolbarPosition == ToolbarPosition.TOP) {
|
||||
@ -206,7 +206,7 @@ class BrowserToolbarView(
|
||||
components.core.historyStorage,
|
||||
lifecycleOwner,
|
||||
sessionId = null,
|
||||
isPrivate = sessionManager.selectedSession?.private ?: false,
|
||||
isPrivate = components.core.store.state.selectedTab?.content?.private ?: false,
|
||||
interactor = interactor,
|
||||
engine = components.core.engine
|
||||
)
|
||||
|
@ -13,6 +13,7 @@ import androidx.fragment.app.DialogFragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.android.synthetic.main.fragment_create_shortcut.*
|
||||
import kotlinx.coroutines.launch
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.loadIntoView
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
@ -32,12 +33,12 @@ class CreateShortcutFragment : DialogFragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val session = requireComponents.core.sessionManager.selectedSession
|
||||
val tab = requireComponents.core.store.state.selectedTab
|
||||
|
||||
if (session == null) {
|
||||
if (tab == null) {
|
||||
dismiss()
|
||||
} else {
|
||||
requireComponents.core.icons.loadIntoView(favicon_image, session.url)
|
||||
requireComponents.core.icons.loadIntoView(favicon_image, tab.content.url)
|
||||
|
||||
cancel_button.setOnClickListener { dismiss() }
|
||||
add_button.setOnClickListener {
|
||||
@ -52,7 +53,7 @@ class CreateShortcutFragment : DialogFragment() {
|
||||
updateAddButtonEnabledState()
|
||||
}
|
||||
|
||||
shortcut_text.setText(session.title)
|
||||
shortcut_text.setText(tab.content.title)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user