diff --git a/deps/db/src/logseq/db/common/initial_data.cljs b/deps/db/src/logseq/db/common/initial_data.cljs index d32b95e880..7b9994301f 100644 --- a/deps/db/src/logseq/db/common/initial_data.cljs +++ b/deps/db/src/logseq/db/common/initial_data.cljs @@ -283,10 +283,10 @@ vec rseq (keep (fn [d] - (and (<= (:v d) today) - (let [e (d/entity db (:e d))] - (when (and (common-entity-util/journal? e) (:db/id e)) - e)))))))) + (when (<= (:v d) today) + (let [e (d/entity db (:e d))] + (when (and (common-entity-util/journal? e) (:db/id e)) + e)))))))) (defn- get-structured-datoms [db] diff --git a/deps/outliner/src/logseq/outliner/property.cljs b/deps/outliner/src/logseq/outliner/property.cljs index 2402d905d5..e47857db9f 100644 --- a/deps/outliner/src/logseq/outliner/property.cljs +++ b/deps/outliner/src/logseq/outliner/property.cljs @@ -684,13 +684,14 @@ (defn class-add-property! [conn class-id property-id] - (when-let [class (d/entity @conn class-id)] - (if (ldb/class? class) - (ldb/transact! conn - [[:db/add (:db/id class) :logseq.property.class/properties property-id]] - {:outliner-op :save-block}) - (throw (ex-info "Can't add a property to a block that isn't a class" - {:class-id class-id :property-id property-id}))))) + (when-not (contains? #{:logseq.property/empty-placeholder} property-id) + (when-let [class (d/entity @conn class-id)] + (if (ldb/class? class) + (ldb/transact! conn + [[:db/add (:db/id class) :logseq.property.class/properties property-id]] + {:outliner-op :save-block}) + (throw (ex-info "Can't add a property to a block that isn't a class" + {:class-id class-id :property-id property-id})))))) (defn class-remove-property! [conn class-id property-id] diff --git a/src/main/frontend/components/dnd.cljs b/src/main/frontend/components/dnd.cljs index 42936ba33c..820076a9fd 100644 --- a/src/main/frontend/components/dnd.cljs +++ b/src/main/frontend/components/dnd.cljs @@ -35,9 +35,14 @@ children])) (rum/defc items - [col {:keys [on-drag-end parent-node vertical? sort-by-inner-element?] - :or {vertical? true}}] - (let [ids (mapv :id col) + [col* {:keys [on-drag-end parent-node vertical? sort-by-inner-element?] + :or {vertical? true}}] + (assert (every? :id col*)) + (when (some #(nil? (:id %)) col*) + (js/console.error "dnd-kit items without id") + (prn :col col*)) + (let [col (filter :id col*) + ids (mapv :id col) items' (bean/->js ids) id->item (zipmap ids col) [items-state set-items] (rum/use-state items') diff --git a/src/main/frontend/components/views.cljs b/src/main/frontend/components/views.cljs index 10d5e2fe76..0cf26bc08b 100644 --- a/src/main/frontend/components/views.cljs +++ b/src/main/frontend/components/views.cljs @@ -1911,7 +1911,8 @@ {pinned true unpinned false} (group-by (fn [item] (contains? pinned-properties (:id item))) (remove (fn [column] - (false? (get visible-columns (:id column)))) + (or (false? (get visible-columns (:id column))) + (nil? (:name column)))) columns)) group-by-property (or (:logseq.property.view/group-by-property view-entity) (db/entity group-by-property-ident)) diff --git a/src/main/frontend/worker/db/validate.cljs b/src/main/frontend/worker/db/validate.cljs index 539a92a36b..6fdf1c535c 100644 --- a/src/main/frontend/worker/db/validate.cljs +++ b/src/main/frontend/worker/db/validate.cljs @@ -7,22 +7,37 @@ (defn- fix-invalid-blocks! [conn errors] - (let [tx-data (keep + (let [tx-data (mapcat (fn [{:keys [entity dispatch-key]}] (let [entity (d/entity @conn (:db/id entity))] (cond + (and (= dispatch-key :block) (nil? (:block/title entity))) + [[:db/retractEntity (:db/id entity)]] + + (and (= dispatch-key :block) (nil? (:block/page entity))) + (let [latest-journal-id (:db/id (first (ldb/get-latest-journals @conn))) + page-id (:db/id (:block/page (:block/parent entity)))] + (cond + page-id + [[:db/add (:db/id entity) :block/page page-id]] + latest-journal-id + [[:db/add (:db/id entity) :block/page latest-journal-id] + [:db/add (:db/id entity) :block/parent latest-journal-id]] + :else + (js/console.error (str "Don't know where to put the block " (:db/id entity))))) + (:block.temp/fully-loaded? entity) - [:db/retract (:db/id entity) :block.temp/fully-loaded?] + [[:db/retract (:db/id entity) :block.temp/fully-loaded?]] (and (:block/page entity) (not (:block/parent entity))) - [:db/add (:db/id entity) :block/parent (:db/id (:block/page entity))] + [[:db/add (:db/id entity) :block/parent (:db/id (:block/page entity))]] (and (not (:block/page entity)) (not (:block/parent entity)) (not (:block/name entity))) - [:db/retractEntity (:db/id entity)] + [[:db/retractEntity (:db/id entity)]] (and (= dispatch-key :property-value-block) (:block/title entity)) - [:db/retract (:db/id entity) :block/title] + [[:db/retract (:db/id entity) :block/title]] (and (ldb/class? entity) (not (:logseq.property.class/extends entity))) - [:db/add (:db/id entity) :logseq.property.class/extends :logseq.class/Root] + [[:db/add (:db/id entity) :logseq.property.class/extends :logseq.class/Root]] (and (or (ldb/class? entity) (ldb/property? entity)) (ldb/internal-page? entity)) - [:db/retract (:db/id entity) :block/tags :logseq.class/Page] + [[:db/retract (:db/id entity) :block/tags :logseq.class/Page]] :else nil))) errors)]