Просмотр исходного кода

enhance(ux): close popup after rtc graph downloaded

Tienson Qin 7 месяцев назад
Родитель
Сommit
6edbbed553
2 измененных файлов с 16 добавлено и 6 удалено
  1. 11 2
      src/main/capacitor/components/popup.cljs
  2. 5 4
      src/main/frontend/handler/events.cljs

+ 11 - 2
src/main/capacitor/components/popup.cljs

@@ -1,6 +1,7 @@
 (ns capacitor.components.popup
   (:require [capacitor.ionic :as ion]
             [capacitor.state :as state]
+            [dommy.core :as dom]
             [logseq.shui.popup.core :as shui-popup]
             [logseq.shui.ui :as shui]
             [rum.core :as rum]))
@@ -46,8 +47,16 @@
 
 (defn popup-hide!
   [& args]
-  (when-not @*last-popup-modal?
-    (apply shui-popup/hide! args)))
+  (cond
+    (= :download-rtc-graph (first args))
+    (do
+      (state/set-popup! nil)
+      (js/setTimeout
+       #(.select (dom/sel1 "ion-tabs") "home") 1000))
+
+    :else
+    (when-not @*last-popup-modal?
+      (apply shui-popup/hide! args))))
 
 (set! shui/popup-show! popup-show!)
 (set! shui/popup-hide! popup-hide!)

+ 5 - 4
src/main/frontend/handler/events.cljs

@@ -388,16 +388,17 @@
       (shui/popup-show!
        nil
        (fn []
-         [:div.flex.items-center.justify-center.mt-8.text-2xl
-          (ui/loading (str "Downloading " graph-name))])))
+         [:div.flex.items-center.justify-center.mt-8
+          (ui/loading (str "Downloading " graph-name))])
+       {:id :download-rtc-graph}))
     (rtc-handler/<rtc-download-graph! graph-name graph-uuid graph-schema-version 60000)
     (when (util/mobile?)
-      (shui/popup-hide!)))
+      (shui/popup-hide! :download-rtc-graph)))
    (p/catch (fn [e]
               (println "RTC download graph failed, error:")
               (js/console.error e)
               (when (util/mobile?)
-                (shui/popup-hide!)
+                (shui/popup-hide! :download-rtc-graph)
                 ;; TODO: notify error
                 )))))