mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/17800: Cleanup and fix request desktop site from home
This commit is contained in:
parent
5ecda4f7c9
commit
1b6aa1dfff
@ -843,7 +843,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|||||||
// has removed all of them, or we couldn't load any) we will pass searchTermOrURL to Gecko
|
// has removed all of them, or we couldn't load any) we will pass searchTermOrURL to Gecko
|
||||||
// and let it try to load whatever was entered.
|
// and let it try to load whatever was entered.
|
||||||
if ((!forceSearch && searchTermOrURL.isUrl()) || engine == null) {
|
if ((!forceSearch && searchTermOrURL.isUrl()) || engine == null) {
|
||||||
if (newTab) {
|
val tabId = if (newTab) {
|
||||||
components.useCases.tabsUseCases.addTab(
|
components.useCases.tabsUseCases.addTab(
|
||||||
url = searchTermOrURL.toNormalizedUrl(),
|
url = searchTermOrURL.toNormalizedUrl(),
|
||||||
flags = flags,
|
flags = flags,
|
||||||
@ -854,10 +854,11 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|||||||
url = searchTermOrURL.toNormalizedUrl(),
|
url = searchTermOrURL.toNormalizedUrl(),
|
||||||
flags = flags
|
flags = flags
|
||||||
)
|
)
|
||||||
|
components.core.store.state.selectedTabId
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestDesktopMode) {
|
if (requestDesktopMode && tabId != null) {
|
||||||
handleRequestDesktopMode()
|
handleRequestDesktopMode(tabId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newTab) {
|
if (newTab) {
|
||||||
@ -885,15 +886,10 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun handleRequestDesktopMode() {
|
internal fun handleRequestDesktopMode(tabId: String) {
|
||||||
val requestDesktopSiteUseCase =
|
components.useCases.sessionUseCases.requestDesktopSite(true, tabId)
|
||||||
components.useCases.sessionUseCases.requestDesktopSite
|
components.core.store.dispatch(ContentAction.UpdateDesktopModeAction(tabId, true))
|
||||||
requestDesktopSiteUseCase.invoke(true)
|
|
||||||
components.core.store.dispatch(
|
|
||||||
ContentAction.UpdateDesktopModeAction(
|
|
||||||
components.core.store.state.selectedTabId.toString(), true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// Reset preference value after opening the tab in desktop mode
|
// Reset preference value after opening the tab in desktop mode
|
||||||
settings().openNextTabInDesktopMode = false
|
settings().openNextTabInDesktopMode = false
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,6 @@ class HomeFragment : Fragment() {
|
|||||||
restoreUseCase = components.useCases.tabsUseCases.restore,
|
restoreUseCase = components.useCases.tabsUseCases.restore,
|
||||||
reloadUrlUseCase = components.useCases.sessionUseCases.reload,
|
reloadUrlUseCase = components.useCases.sessionUseCases.reload,
|
||||||
selectTabUseCase = components.useCases.tabsUseCases.selectTab,
|
selectTabUseCase = components.useCases.tabsUseCases.selectTab,
|
||||||
requestDesktopSiteUseCase = components.useCases.sessionUseCases.requestDesktopSite,
|
|
||||||
fragmentStore = homeFragmentStore,
|
fragmentStore = homeFragmentStore,
|
||||||
navController = findNavController(),
|
navController = findNavController(),
|
||||||
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
|
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
|
||||||
|
@ -192,7 +192,6 @@ class DefaultSessionControlController(
|
|||||||
private val restoreUseCase: TabsUseCases.RestoreUseCase,
|
private val restoreUseCase: TabsUseCases.RestoreUseCase,
|
||||||
private val reloadUrlUseCase: SessionUseCases.ReloadUrlUseCase,
|
private val reloadUrlUseCase: SessionUseCases.ReloadUrlUseCase,
|
||||||
private val selectTabUseCase: TabsUseCases.SelectTabUseCase,
|
private val selectTabUseCase: TabsUseCases.SelectTabUseCase,
|
||||||
private val requestDesktopSiteUseCase: SessionUseCases.RequestDesktopSiteUseCase,
|
|
||||||
private val fragmentStore: HomeFragmentStore,
|
private val fragmentStore: HomeFragmentStore,
|
||||||
private val navController: NavController,
|
private val navController: NavController,
|
||||||
private val viewLifecycleScope: CoroutineScope,
|
private val viewLifecycleScope: CoroutineScope,
|
||||||
@ -410,14 +409,14 @@ class DefaultSessionControlController(
|
|||||||
}
|
}
|
||||||
event?.let { activity.metrics.track(it) }
|
event?.let { activity.metrics.track(it) }
|
||||||
|
|
||||||
addTabUseCase.invoke(
|
val tabId = addTabUseCase.invoke(
|
||||||
url = appendSearchAttributionToUrlIfNeeded(url),
|
url = appendSearchAttributionToUrlIfNeeded(url),
|
||||||
selectTab = true,
|
selectTab = true,
|
||||||
startLoading = true
|
startLoading = true
|
||||||
)
|
)
|
||||||
|
|
||||||
if (settings.openNextTabInDesktopMode) {
|
if (settings.openNextTabInDesktopMode) {
|
||||||
activity.handleRequestDesktopMode()
|
activity.handleRequestDesktopMode(tabId)
|
||||||
}
|
}
|
||||||
activity.openToBrowser(BrowserDirection.FromHome)
|
activity.openToBrowser(BrowserDirection.FromHome)
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,6 @@ class DefaultSessionControlControllerTest {
|
|||||||
every { analytics.metrics } returns metrics
|
every { analytics.metrics } returns metrics
|
||||||
|
|
||||||
val restoreUseCase: TabsUseCases.RestoreUseCase = mockk(relaxed = true)
|
val restoreUseCase: TabsUseCases.RestoreUseCase = mockk(relaxed = true)
|
||||||
val requestDesktopSiteUseCase: SessionUseCases.RequestDesktopSiteUseCase = mockk(relaxed = true)
|
|
||||||
|
|
||||||
controller = spyk(DefaultSessionControlController(
|
controller = spyk(DefaultSessionControlController(
|
||||||
activity = activity,
|
activity = activity,
|
||||||
@ -158,7 +157,6 @@ class DefaultSessionControlControllerTest {
|
|||||||
reloadUrlUseCase = reloadUrlUseCase.reload,
|
reloadUrlUseCase = reloadUrlUseCase.reload,
|
||||||
selectTabUseCase = selectTabUseCase.selectTab,
|
selectTabUseCase = selectTabUseCase.selectTab,
|
||||||
restoreUseCase = restoreUseCase,
|
restoreUseCase = restoreUseCase,
|
||||||
requestDesktopSiteUseCase = requestDesktopSiteUseCase,
|
|
||||||
fragmentStore = fragmentStore,
|
fragmentStore = fragmentStore,
|
||||||
navController = navController,
|
navController = navController,
|
||||||
viewLifecycleScope = scope,
|
viewLifecycleScope = scope,
|
||||||
|
Loading…
Reference in New Issue
Block a user