mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 06:34:34 +00:00
fix: ui keep refresh with custom journal format
This commit is contained in:
@@ -69,6 +69,10 @@
|
||||
[]
|
||||
(journal-name))
|
||||
|
||||
(defn today-name
|
||||
[]
|
||||
(tf/unparse mmm-do-yyyy-formatter (t/today)))
|
||||
|
||||
(defn tomorrow
|
||||
[]
|
||||
(journal-name (t/plus (start-of-day (tl/local-now)) (t/days 1))))
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
(defn <create!
|
||||
([title]
|
||||
(<create! title {}))
|
||||
([title {:keys [redirect? today-journal?]
|
||||
([title {:keys [redirect? today-journal? class?]
|
||||
:or {redirect? true}
|
||||
:as options}]
|
||||
(when (string? title)
|
||||
@@ -64,24 +64,27 @@
|
||||
:error)
|
||||
:else
|
||||
(when-not (string/blank? title')
|
||||
(p/let [options' (cond-> (update options :tags concat (:block/tags parsed-result))
|
||||
(nil? (:split-namespace? options))
|
||||
(assoc :split-namespace? true))
|
||||
[_page-name page-uuid] (ui-outliner-tx/transact!
|
||||
{:outliner-op :create-page}
|
||||
(outliner-op/create-page! title' options'))
|
||||
page (db/get-page (or page-uuid title'))]
|
||||
(when redirect?
|
||||
(route-handler/redirect-to-page! page-uuid)
|
||||
(when-not today-journal?
|
||||
(js/setTimeout
|
||||
(fn []
|
||||
(when-let [block-add-button (->> (dom/sel ".block-add-button")
|
||||
(filter #(= (str (:db/id page)) (dom/attr % "parentblockid")))
|
||||
first)]
|
||||
(.click block-add-button)))
|
||||
200)))
|
||||
page)))))))
|
||||
(p/let [existing-page (when-not class? (db/get-page title'))]
|
||||
(if existing-page
|
||||
existing-page
|
||||
(p/let [options' (cond-> (update options :tags concat (:block/tags parsed-result))
|
||||
(nil? (:split-namespace? options))
|
||||
(assoc :split-namespace? true))
|
||||
[_page-name page-uuid] (ui-outliner-tx/transact!
|
||||
{:outliner-op :create-page}
|
||||
(outliner-op/create-page! title' options'))
|
||||
page (db/get-page (or page-uuid title'))]
|
||||
(when redirect?
|
||||
(route-handler/redirect-to-page! page-uuid)
|
||||
(when-not today-journal?
|
||||
(js/setTimeout
|
||||
(fn []
|
||||
(when-let [block-add-button (->> (dom/sel ".block-add-button")
|
||||
(filter #(= (str (:db/id page)) (dom/attr % "parentblockid")))
|
||||
first)]
|
||||
(.click block-add-button)))
|
||||
200)))
|
||||
page)))))))))
|
||||
|
||||
;; favorite fns
|
||||
;; ============
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.plugin :as plugin-handler]
|
||||
[frontend.handler.property :as property-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.modules.outliner.op :as outliner-op]
|
||||
[frontend.modules.outliner.ui :as ui-outliner-tx]
|
||||
[frontend.state :as state]
|
||||
@@ -258,16 +257,14 @@
|
||||
(not config/publishing?))
|
||||
(when-let [title (date/today)]
|
||||
(state/set-today! title)
|
||||
(let [today-page (util/page-name-sanity-lc title)
|
||||
create-f (fn []
|
||||
(p/let [result (<create! title {:redirect? false
|
||||
:split-namespace? false
|
||||
:today-journal? true})]
|
||||
(ui-handler/re-render-root!)
|
||||
(plugin-handler/hook-plugin-app :today-journal-created {:title today-page})
|
||||
result))]
|
||||
(when-not (db/get-page today-page)
|
||||
(create-f)))))))
|
||||
(p/let [today-page (util/page-name-sanity-lc title)
|
||||
page (ldb/get-journal-page (db/get-db) (date/today-name))]
|
||||
(when-not page
|
||||
(p/let [result (<create! title {:redirect? false
|
||||
:split-namespace? false
|
||||
:today-journal? true})]
|
||||
(plugin-handler/hook-plugin-app :today-journal-created {:title today-page})
|
||||
result)))))))
|
||||
|
||||
(defn open-today-in-sidebar
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user