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

pull/10016/head
Tienson Qin 2023-06-26 19:19:08 +08:00
parent 7e44ff09a8
commit ca85775e20
1 changed files with 11 additions and 9 deletions

View File

@ -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
[]