浏览代码

Always add target of `redirect-to-page!` to 'Recent' list.

This change will put way more visited pages in the 'Recent' list, which (to me) feels better than the current behaviour.
Moritz Ulrich 3 年之前
父节点
当前提交
d7759aeb79

+ 0 - 3
src/main/frontend/components/block.cljs

@@ -34,7 +34,6 @@
             [frontend.components.plugins :as plugins]
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.block :as block-handler]
-            [frontend.handler.recent :as recent-handler]
             [frontend.handler.dnd :as dnd]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.repeated :as repeated]
@@ -381,8 +380,6 @@
       :on-mouse-down
       (fn [e]
         (util/stop e)
-        (when redirect-page-name
-          (recent-handler/add-page-to-recent! (state/get-current-repo) redirect-page-name))
         (let [create-first-block! (fn []
                                     (when-not (editor-handler/add-default-title-property-if-needed! redirect-page-name)
                                       (editor-handler/insert-first-page-block-if-not-exists! redirect-page-name)))]

+ 0 - 2
src/main/frontend/handler/editor.cljs

@@ -25,7 +25,6 @@
             [frontend.handler.export :as export]
             [frontend.handler.image :as image-handler]
             [frontend.handler.notification :as notification]
-            [frontend.handler.recent :as recent-handler]
             [frontend.handler.repeated :as repeated]
             [frontend.handler.repo :as repo-handler]
             [frontend.handler.route :as route-handler]
@@ -1287,7 +1286,6 @@
       (let [page-name (string/lower-case page)]
         (state/clear-edit!)
         (insert-first-page-block-if-not-exists! page-name)
-        (recent-handler/add-page-to-recent! (state/get-current-repo) page-name)
         (route-handler/redirect-to-page! page-name)))))
 
 (defn open-link-in-sidebar!

+ 4 - 0
src/main/frontend/handler/route.cljs

@@ -3,6 +3,7 @@
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.handler.ui :as ui-handler]
+            [frontend.handler.recent :as recent-handler]
             [frontend.handler.search :as search-handler]
             [frontend.state :as state]
             [frontend.text :as text]
@@ -28,13 +29,16 @@
 
 (defn redirect-to-page!
   ([page-name]
+   (recent-handler/add-page-to-recent! (state/get-current-repo) page-name)
    (redirect! {:to :page
                :path-params {:name (str page-name)}}))
   ([page-name anchor]
+   (recent-handler/add-page-to-recent! (state/get-current-repo) page-name)
    (redirect! {:to :page
                :path-params {:name (str page-name)}
                :query-params {:anchor anchor}}))
   ([page-name anchor push]
+   (recent-handler/add-page-to-recent! (state/get-current-repo) page-name)
    (redirect! {:to :page
                :path-params {:name (str page-name)}
                :query-params {:anchor anchor}