Browse Source

enhance(capacitor): switch graphs

charlie 7 months ago
parent
commit
a6e6890a08
2 changed files with 8 additions and 3 deletions
  1. 4 2
      src/main/capacitor/app.cljs
  2. 4 1
      src/main/capacitor/externals.js

+ 4 - 2
src/main/capacitor/app.cljs

@@ -6,6 +6,7 @@
             [frontend.db.react :as react]
             [frontend.util :as util]
             [rum.core :as rum]
+            [frontend.rum :as frum]
             [promesa.core :as p]
             [capacitor.ionic :as ionic]
             [capacitor.state :as state]
@@ -230,14 +231,15 @@
 
 (rum/defc main []
   (let [nav-ref (rum/use-ref nil)
-        [_ set-nav-root!] (state/use-nav-root)]
+        [_ set-nav-root!] (state/use-nav-root)
+        current-repo (frum/use-atom-in fstate/state :git/current-repo)]
 
     ;; global
     (rum/use-effect!
       (fn []
         (some-> js/window.externalsjs (.settleStatusBar))
         (some-> js/window.externalsjs (.initGlobalListeners)))
-      [])
+      [current-repo])
 
     ;; navigation
     (rum/use-effect!

+ 4 - 1
src/main/capacitor/externals.js

@@ -32,11 +32,14 @@ function initGlobalListeners () {
   }
 }
 
+let initialSettled = false
+
 const settleStatusBar = async () => {
   if (Capacitor.getPlatform() === 'android') {
     try {
       await Capacitor.Plugins.App.getInfo() // 等待平台初始化??
-      await (new Promise((r) => setTimeout(r, 500)))
+      await (new Promise((r) => setTimeout(r, initialSettled ? 300 : 500)))
+      if (!initialSettled) { initialSettled = true }
       await StatusBar.setStyle({ style: Style.Light }) // 可选:设置状态栏样式
       await StatusBar.setBackgroundColor({ color: '#ffffff' })
       await StatusBar.setOverlaysWebView({ overlay: true })