mirror of
https://github.com/logseq/logseq.git
synced 2026-05-24 20:54:09 +00:00
fix: path bookkeeping
This commit is contained in:
@@ -34,6 +34,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel
|
||||
// Each stack has its own native VC stack, just like paths.
|
||||
private var stackViewControllerStacks: [String: [UIViewController]] = [:]
|
||||
|
||||
private var routeChangeObserver: NSObjectProtocol?
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// MARK: Helpers
|
||||
// ---------------------------------------------------------
|
||||
@@ -278,9 +280,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel
|
||||
// -----------------------------
|
||||
let previousStack = pathStack
|
||||
|
||||
if pathStack.count > 1 {
|
||||
if let to = toIndex {
|
||||
pathStack = Array(pathStack.prefix(to + 1))
|
||||
} else if pathStack.count > 1 {
|
||||
_ = pathStack.popLast()
|
||||
}
|
||||
if pathStack.isEmpty {
|
||||
pathStack = [toVC.targetPath]
|
||||
}
|
||||
if let last = pathStack.last, last != toVC.targetPath {
|
||||
pathStack[pathStack.count - 1] = toVC.targetPath
|
||||
}
|
||||
@@ -382,7 +389,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel
|
||||
// ---------------------------------------------------------
|
||||
|
||||
private func observeRouteChanges() {
|
||||
NotificationCenter.default.addObserver(
|
||||
if routeChangeObserver != nil {
|
||||
return
|
||||
}
|
||||
|
||||
routeChangeObserver = NotificationCenter.default.addObserver(
|
||||
forName: UILocalPlugin.routeChangeNotification,
|
||||
object: nil,
|
||||
queue: .main
|
||||
@@ -417,8 +428,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel
|
||||
let vc = NativePageViewController(path: "/")
|
||||
nav.setViewControllers([vc], animated: false)
|
||||
self.setViewControllers([vc], for: "home")
|
||||
|
||||
// 👈 Do NOTHING to nav.viewControllers or SharedWebViewController here.
|
||||
SharedWebViewController.instance.clearPlaceholder()
|
||||
SharedWebViewController.instance.attach(to: vc)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ public class LiquidTabsPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
|
||||
// MARK: - Events to JS
|
||||
|
||||
func notifyTabSelected(id: String) {
|
||||
notifyListeners("tabSelected", data: ["id": id])
|
||||
func notifyTabSelected(id: String, reselected: Bool = false) {
|
||||
notifyListeners("tabSelected", data: ["id": id, "reselected": reselected])
|
||||
}
|
||||
|
||||
func notifySearchChanged(query: String) {
|
||||
|
||||
@@ -146,7 +146,7 @@ private struct LiquidTabs26View: View {
|
||||
navController.popToRootViewController(animated: true)
|
||||
|
||||
if let id = store.tabId(for: selection) {
|
||||
LiquidTabsPlugin.shared?.notifyTabSelected(id: id)
|
||||
LiquidTabsPlugin.shared?.notifyTabSelected(id: id, reselected: true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ private struct LiquidTabs16View: View {
|
||||
// Re-tap: pop to root
|
||||
if id == store.selectedId {
|
||||
navController.popToRootViewController(animated: true)
|
||||
LiquidTabsPlugin.shared?.notifyTabSelected(id: id)
|
||||
LiquidTabsPlugin.shared?.notifyTabSelected(id: id, reselected: true)
|
||||
} else {
|
||||
store.selectedId = id
|
||||
LiquidTabsPlugin.shared?.notifyTabSelected(id: id)
|
||||
|
||||
@@ -49,7 +49,7 @@ import Capacitor
|
||||
}
|
||||
|
||||
// 2) Detach from previous parent
|
||||
if let previous = currentParent {
|
||||
if let previous = vc.parent {
|
||||
vc.willMove(toParent: nil)
|
||||
vc.view.removeFromSuperview()
|
||||
vc.removeFromParent()
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
(fn [data]
|
||||
(when-let [id (.-id data)]
|
||||
(when-not (string/blank? id)
|
||||
(route-handler/redirect-to-page! id {:push (mobile-util/native-android?)})))))))
|
||||
(route-handler/redirect-to-page! id {:push (mobile-util/native-platform?)})))))))
|
||||
|
||||
(defn add-keyboard-hack-listener!
|
||||
"Listen for Backspace or Enter while the invisible keyboard field is focused."
|
||||
@@ -112,7 +112,7 @@
|
||||
(cond
|
||||
reselected?
|
||||
(do
|
||||
(when (mobile-util/native-android?)
|
||||
(when (mobile-util/native-platform?)
|
||||
(mobile-nav/pop-to-root! tab))
|
||||
(mobile-state/set-tab! tab)
|
||||
(when (= "home" tab)
|
||||
|
||||
Reference in New Issue
Block a user