fix: calendar doesn't redirect to journal page

This commit is contained in:
Tienson Qin
2025-11-24 00:02:49 +08:00
parent bead5138fb
commit af0abe1a6f
2 changed files with 4 additions and 25 deletions

View File

@@ -8,6 +8,7 @@
[frontend.db :as db]
[frontend.db.conn :as db-conn]
[frontend.handler.page :as page-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.user :as user-handler]
[frontend.mobile.util :as mobile-util]
[frontend.state :as state]
@@ -29,9 +30,9 @@
(let [apply-date! (fn [date]
(let [page-name (date/journal-name (gdate/Date. (js/Date. date)))]
(if-let [journal (db/get-page page-name)]
(mobile-state/open-block-modal! journal)
(-> (page-handler/<create! page-name {:redirect? false})
(p/then #(mobile-state/open-block-modal! (db/get-page page-name)))))))]
(route-handler/redirect-to-page! (:block/uuid journal))
(p/let [page (page-handler/<create! page-name {:redirect? false})]
(route-handler/redirect-to-page! (:block/uuid page))))))]
(-> (.showDatePicker mobile-util/ui-local)
(p/then (fn [^js e] (some-> e (.-value) (apply-date!)))))))

View File

@@ -13,28 +13,6 @@
(defn use-search-last-input-at []
(r/use-atom *search-last-input-at))
(defonce *modal-blocks (atom []))
(defonce *blocks-navigation-history (atom []))
(defn open-block-modal!
[block]
(when (:db/id block)
(reset! *modal-blocks [block])
(when-not (= (:db/id block) (:db/id (last @*blocks-navigation-history)))
(swap! *blocks-navigation-history conj block))))
(defn close-block-modal!
"Close top block sheet"
[]
(reset! *modal-blocks [])
(reset! *blocks-navigation-history []))
(defn pop-navigation-history!
[]
(when (seq @*blocks-navigation-history)
(let [stack (swap! *blocks-navigation-history pop)]
(when (seq stack)
(reset! *modal-blocks [(last stack)])))))
(defonce *popup-data (atom nil))
(defn set-popup!
[data]