فهرست منبع

fix: don't update :recent/pages when restoring

Tienson Qin 2 سال پیش
والد
کامیت
ca85775e20
1فایلهای تغییر یافته به همراه11 افزوده شده و 9 حذف شده
  1. 11 9
      src/main/frontend/handler/db_based/recent.cljs

+ 11 - 9
src/main/frontend/handler/db_based/recent.cljs

@@ -1,19 +1,21 @@
 (ns frontend.handler.db-based.recent
   "Fns related to recent pages feature"
   (:require [frontend.db :as db]
+            [frontend.state :as state]
             [logseq.graph-parser.util :as gp-util]))
 
 (defn add-page-to-recent!
   [repo page click-from-recent?]
-  (when-let [page-uuid (if (uuid? page)
-                         page
-                         (:block/uuid (db/entity [:block/name (gp-util/page-name-sanity-lc page)])))]
-    (let [pages (or (db/get-key-value repo :recent/pages)
-                    '())]
-      (when (or (and click-from-recent? (not ((set pages) page-uuid)))
-                (not click-from-recent?))
-        (let [new-pages (take 15 (distinct (cons page-uuid pages)))]
-          (db/set-key-value repo :recent/pages new-pages))))))
+  (when-not (:db/restoring? @state/state)
+    (when-let [page-uuid (if (uuid? page)
+                           nil
+                           (:block/uuid (db/entity [:block/name (gp-util/page-name-sanity-lc page)])))]
+      (let [pages (or (db/get-key-value repo :recent/pages)
+                      '())]
+        (when (or (and click-from-recent? (not ((set pages) page-uuid)))
+                  (not click-from-recent?))
+          (let [new-pages (take 15 (distinct (cons page-uuid pages)))]
+            (db/set-key-value repo :recent/pages new-pages)))))))
 
 (defn get-recent-pages
   []