Bladeren bron

fix(recents): zoomed block uuid should not be added to recents

Andelf 1 jaar geleden
bovenliggende
commit
a81ec6e215
1 gewijzigde bestanden met toevoegingen van 11 en 5 verwijderingen
  1. 11 5
      src/main/frontend/handler/recent.cljs

+ 11 - 5
src/main/frontend/handler/recent.cljs

@@ -1,14 +1,20 @@
 (ns frontend.handler.recent
   "Fns related to recent pages feature"
-  (:require [frontend.db :as db]))
+  (:require [frontend.db :as db]
+            [frontend.db.model :as model]))
 
 (defn add-page-to-recent!
-  [repo page click-from-recent?]
+  [repo page-name-or-block-uuid click-from-recent?]
   (let [pages (or (db/get-key-value repo :recent/pages)
-                  '())]
-    (when (or (and click-from-recent? (not ((set pages) page)))
+                  '())
+        page-name (if (uuid? page-name-or-block-uuid)
+                    (when-let [block (model/get-block-by-uuid page-name-or-block-uuid)]
+                      (get-in block [:block/page :block/original-name]))
+                    page-name-or-block-uuid)]
+
+    (when (or (and click-from-recent? (not ((set pages) page-name)))
               (not click-from-recent?))
-      (let [new-pages (take 15 (distinct (cons page pages)))]
+      (let [new-pages (take 15 (distinct (cons page-name pages)))]
         (db/set-key-value repo :recent/pages new-pages)))))
 
 (defn update-or-add-renamed-page [repo old-page-name new-page-name]