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