diff --git a/common/src/app/common/files/changes_builder.cljc b/common/src/app/common/files/changes_builder.cljc index bb05a92624..fb87b5f9e3 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -311,10 +311,12 @@ (defn del-page [changes page] - (-> changes - (update :redo-changes conj {:type :del-page :id (:id page)}) - (update :undo-changes conj {:type :add-page :id (:id page) :page page}) - (apply-changes-local))) + (let [page-id (:id page)] + (assert (some? page-id) "page must have a valid :id") + (-> changes + (update :redo-changes conj {:type :del-page :id page-id}) + (update :undo-changes conj {:type :add-page :id page-id :page page}) + (apply-changes-local)))) (defn move-page [changes page-id index prev-index] diff --git a/frontend/src/app/main/data/workspace/pages.cljs b/frontend/src/app/main/data/workspace/pages.cljs index 6bff07b281..9ef4a20f19 100644 --- a/frontend/src/app/main/data/workspace/pages.cljs +++ b/frontend/src/app/main/data/workspace/pages.cljs @@ -379,15 +379,18 @@ pages (:pages fdata) index (d/index-of pages id) - page (get pindex id) - page (assoc page :index index) - pages (filter #(not= % id) pages) + page (get pindex id)] - changes (-> (pcb/empty-changes it) - (pcb/with-library-data fdata) - (delete-page-components page) - (pcb/del-page page))] + (if (nil? page) + (rx/empty) + (let [page (assoc page :index index) + pages (filter #(not= % id) pages) - (rx/of (dch/commit-changes changes) - (when (= id (:current-page-id state)) - (dcm/go-to-workspace {:page-id (first pages)}))))))) + changes (-> (pcb/empty-changes it) + (pcb/with-library-data fdata) + (delete-page-components page) + (pcb/del-page page))] + + (rx/of (dch/commit-changes changes) + (when (= id (:current-page-id state)) + (dcm/go-to-workspace {:page-id (first pages)})))))))))