Browse Source

fix: no need to set capture tab

Tienson Qin 1 day ago
parent
commit
55073d3521
2 changed files with 16 additions and 25 deletions
  1. 13 18
      src/main/mobile/bottom_tabs.cljs
  2. 3 7
      src/main/mobile/components/popup.cljs

+ 13 - 18
src/main/mobile/bottom_tabs.cljs

@@ -84,28 +84,23 @@
   (do
     (add-tab-selected-listener!
      (fn [tab]
-       (let [exit-quick-add? (= "quick-add" @*previous-tab)
-             exit-search? (= "search" @*previous-tab)]
-         (reset! mobile-state/*search-input "")
-         (when-not (or (contains? #{"quick-add"} tab)
-                       (= tab @*previous-tab))
-           (when-not (or exit-quick-add? exit-search?)
-             (mobile-nav/reset-route!))
-           (mobile-state/set-tab! tab))
+       (if (= tab "capture")
+         (editor-handler/show-quick-add)
+         (let [exit-search? (= "search" @*previous-tab)]
+           (when-not (= tab @*previous-tab)
+             (when-not exit-search?
+               (mobile-nav/reset-route!))
+             (mobile-state/set-tab! tab))
 
-         (case tab
-           "home"
-           (when-not exit-quick-add?
-             (util/scroll-to-top false))
-           "quick-add"
-           (editor-handler/show-quick-add)
+           (case tab
+             "home"
+             (util/scroll-to-top false)
              ;; TODO: support longPress detection
              ;; (if (= "longPress" interaction)
              ;;   (state/pub-event! [:mobile/start-audio-record])
              ;;   (editor-handler/show-quick-add))
-           nil)
-
-         (reset! *previous-tab tab))))
+             nil)
+           (reset! *previous-tab tab)))))
 
     (add-watch mobile-state/*tab ::select-tab
                (fn [_ _ _old new]
@@ -125,5 +120,5 @@
   (configure-tabs
    [{:id "home"       :title "Home"       :systemImage "house" :role "normal"}
     {:id "favorites"  :title "Favorites"  :systemImage "star"  :role "normal"}
-    {:id "quick-add"  :title "Capture"    :systemImage "tray"  :role "normal"}
+    {:id "capture"    :title "Capture"    :systemImage "tray"  :role "normal"}
     {:id "settings"   :title "Settings"   :systemImage "gear"  :role "normal"}]))

+ 3 - 7
src/main/mobile/components/popup.cljs

@@ -52,13 +52,9 @@
 
       dismissing?
       (when (some? @mobile-state/*popup-data)
-        (let [quick-add? (mobile-state/quick-add-open?)
-              current-tab @mobile-state/*tab]
-          (state/pub-event! [:mobile/clear-edit])
-          (mobile-state/set-popup! nil)
-          (reset! *last-popup-data nil)
-          (when (and current-tab quick-add?)
-            (mobile-state/set-tab! current-tab))))
+        (state/pub-event! [:mobile/clear-edit])
+        (mobile-state/set-popup! nil)
+        (reset! *last-popup-data nil))
 
       :else
       nil)))