mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
For #2584: Adds opening tab collections
This commit is contained in:
parent
afbe397f94
commit
a3f25b9f77
@ -72,6 +72,13 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|||||||
private var sessionObserver: SessionManager.Observer? = null
|
private var sessionObserver: SessionManager.Observer? = null
|
||||||
private var tabCollectionObserver: Observer<List<TabCollection>>? = null
|
private var tabCollectionObserver: Observer<List<TabCollection>>? = null
|
||||||
|
|
||||||
|
private val singleSessionObserver = object : Session.Observer {
|
||||||
|
override fun onTitleChanged(session: Session, title: String) {
|
||||||
|
super.onTitleChanged(session, title)
|
||||||
|
emitSessionChanges()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var homeMenu: HomeMenu? = null
|
private var homeMenu: HomeMenu? = null
|
||||||
|
|
||||||
var deleteSessionJob: (suspend () -> Unit)? = null
|
var deleteSessionJob: (suspend () -> Unit)? = null
|
||||||
@ -357,7 +364,10 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|||||||
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "1575")
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "1575")
|
||||||
}
|
}
|
||||||
is CollectionAction.OpenTabs -> {
|
is CollectionAction.OpenTabs -> {
|
||||||
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "2205")
|
invokePendingDeleteSessionJob()
|
||||||
|
action.collection.tabs.forEach {
|
||||||
|
requireComponents.useCases.tabsUseCases.addTab.invoke(it.url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is CollectionAction.ShareTabs -> {
|
is CollectionAction.ShareTabs -> {
|
||||||
val shareText = action.collection.tabs.joinToString("\n") {
|
val shareText = action.collection.tabs.joinToString("\n") {
|
||||||
@ -433,11 +443,13 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|||||||
val observer = object : SessionManager.Observer {
|
val observer = object : SessionManager.Observer {
|
||||||
override fun onSessionAdded(session: Session) {
|
override fun onSessionAdded(session: Session) {
|
||||||
super.onSessionAdded(session)
|
super.onSessionAdded(session)
|
||||||
|
session.register(singleSessionObserver)
|
||||||
emitSessionChanges()
|
emitSessionChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSessionRemoved(session: Session) {
|
override fun onSessionRemoved(session: Session) {
|
||||||
super.onSessionRemoved(session)
|
super.onSessionRemoved(session)
|
||||||
|
session.unregister(singleSessionObserver)
|
||||||
emitSessionChanges()
|
emitSessionChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,11 +460,17 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|||||||
|
|
||||||
override fun onSessionsRestored() {
|
override fun onSessionsRestored() {
|
||||||
super.onSessionsRestored()
|
super.onSessionsRestored()
|
||||||
|
requireComponents.core.sessionManager.sessions.forEach {
|
||||||
|
it.register(singleSessionObserver)
|
||||||
|
}
|
||||||
emitSessionChanges()
|
emitSessionChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAllSessionsRemoved() {
|
override fun onAllSessionsRemoved() {
|
||||||
super.onAllSessionsRemoved()
|
super.onAllSessionsRemoved()
|
||||||
|
requireComponents.core.sessionManager.sessions.forEach {
|
||||||
|
it.unregister(singleSessionObserver)
|
||||||
|
}
|
||||||
emitSessionChanges()
|
emitSessionChanges()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user