|
|
@@ -96,44 +96,39 @@
|
|
|
|
|
|
(defn- fix-page-tags
|
|
|
"Add missing attributes and remove #Page when inserting or updating block/title with inline tags"
|
|
|
- [{:keys [db-after tx-data tx-meta]}]
|
|
|
- (when-not (rtc-tx-or-download-graph? tx-meta)
|
|
|
- (let [page-tag (d/entity db-after :logseq.class/Page)
|
|
|
- tag (d/entity db-after :logseq.class/Tag)]
|
|
|
- (assert page-tag "Page tag doesn't exist")
|
|
|
- (->>
|
|
|
- (keep
|
|
|
- (fn [datom]
|
|
|
- (cond
|
|
|
- ;; add missing :db/ident and :logseq.property.class/extends for new tag
|
|
|
- (and (= :block/tags (:a datom))
|
|
|
- (:added datom)
|
|
|
- (= (:v datom) (:db/id tag)))
|
|
|
- (let [t (d/entity db-after (:e datom))]
|
|
|
- (when (and (not (ldb/inline-tag? (:block/raw-title t) tag))
|
|
|
- (not (:db/ident t))) ; new tag without db/ident
|
|
|
- (let [eid (:db/id t)]
|
|
|
- [[:db/add eid :db/ident (db-class/create-user-class-ident-from-name db-after (:block/title t))]
|
|
|
- [:db/add eid :logseq.property.class/extends :logseq.class/Root]
|
|
|
- [:db/retract eid :block/tags :logseq.class/Page]])))
|
|
|
+ [{:keys [db-after tx-data]}]
|
|
|
+ (let [page-tag (d/entity db-after :logseq.class/Page)
|
|
|
+ tag (d/entity db-after :logseq.class/Tag)]
|
|
|
+ (assert page-tag "Page tag doesn't exist")
|
|
|
+ (mapcat
|
|
|
+ (fn [datom]
|
|
|
+ (when (and (= :block/tags (:a datom))
|
|
|
+ (:added datom))
|
|
|
+ (let [t (d/entity db-after (:e datom))]
|
|
|
+ (cond
|
|
|
+ ;; add missing :db/ident and :logseq.property.class/extends for new tag
|
|
|
+ (and (= (:v datom) (:db/id tag))
|
|
|
+ (not (ldb/inline-tag? (:block/raw-title t) tag))
|
|
|
+ (not (:db/ident t)))
|
|
|
+ (let [eid (:db/id t)]
|
|
|
+ [[:db/add eid :db/ident (db-class/create-user-class-ident-from-name db-after (:block/title t))]
|
|
|
+ [:db/add eid :logseq.property.class/extends :logseq.class/Root]
|
|
|
+ [:db/retract eid :block/tags :logseq.class/Page]])
|
|
|
|
|
|
- ;; remove #Page from tags/journals/whiteboards, etc.
|
|
|
- (and (= :block/tags (:a datom))
|
|
|
- (:added datom)
|
|
|
- (= (:db/id page-tag) (:v datom)))
|
|
|
- (let [tags (->> (d/entity db-after (:e datom))
|
|
|
- :block/tags
|
|
|
- (map :db/ident)
|
|
|
- (remove #{:logseq.class/Page}))]
|
|
|
- (when (and (seq tags)
|
|
|
+ ;; remove #Page from tags/journals/whiteboards, etc.
|
|
|
+ (= (:db/id page-tag) (:v datom))
|
|
|
+ (let [tags (->> (d/entity db-after (:e datom))
|
|
|
+ :block/tags
|
|
|
+ (map :db/ident)
|
|
|
+ (remove #{:logseq.class/Page}))]
|
|
|
+ (when (and (seq tags)
|
|
|
;; has other page-classes other than `:logseq.class/Page`
|
|
|
- (some db-class/page-classes tags))
|
|
|
- [[:db/retract (:e datom) :block/tags :logseq.class/Page]]))
|
|
|
+ (some db-class/page-classes tags))
|
|
|
+ [[:db/retract (:e datom) :block/tags :logseq.class/Page]]))
|
|
|
|
|
|
- :else
|
|
|
- nil))
|
|
|
- tx-data)
|
|
|
- (apply concat)))))
|
|
|
+ :else
|
|
|
+ nil))))
|
|
|
+ tx-data)))
|
|
|
|
|
|
(defn- remove-inline-page-class-from-title
|
|
|
"Remove inline page tag from title"
|