For #9536: Open report issue tab depending on current browsing mode.
Checking if session is private uses the new browser state API.
This commit is contained in:
parent
8440f1867a
commit
83d2208c6b
|
@ -19,6 +19,7 @@ import kotlinx.coroutines.launch
|
|||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.browser.state.selector.findTab
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.concept.engine.prompt.ShareData
|
||||
import mozilla.components.support.ktx.kotlin.isUrl
|
||||
|
@ -211,10 +212,12 @@ class DefaultBrowserToolbarController(
|
|||
activity.components.analytics.metrics.track(Event.FindInPageOpened)
|
||||
}
|
||||
ToolbarMenu.Item.ReportIssue -> {
|
||||
val currentUrl = currentSession?.url
|
||||
currentUrl?.apply {
|
||||
val reportUrl = String.format(BrowserFragment.REPORT_SITE_ISSUE_URL, this)
|
||||
activity.components.useCases.tabsUseCases.addTab.invoke(reportUrl)
|
||||
val selectedTab = activity.components.core.store.state.selectedTab
|
||||
selectedTab?.let {
|
||||
val currentUrl = it.content.url
|
||||
val reportUrl = String.format(BrowserFragment.REPORT_SITE_ISSUE_URL, currentUrl)
|
||||
val private = it.content.private
|
||||
reportSiteIssue(reportUrl, private)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,6 +326,14 @@ class DefaultBrowserToolbarController(
|
|||
}
|
||||
}
|
||||
|
||||
private fun reportSiteIssue(reportUrl: String, private: Boolean) {
|
||||
if (private) {
|
||||
activity.components.useCases.tabsUseCases.addPrivateTab.invoke(reportUrl)
|
||||
} else {
|
||||
activity.components.useCases.tabsUseCases.addTab.invoke(reportUrl)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
private fun trackToolbarItemInteraction(item: ToolbarMenu.Item) {
|
||||
val eventItem = when (item) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user