From b2e7bb6be144d73692db27a5bfc463cd22b17e4b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 3 Jun 2021 17:12:40 +0200 Subject: [PATCH 1/2] :bug: Properly handle nil values on `update-shapes` function. --- .../src/app/main/data/workspace/changes.cljs | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/main/data/workspace/changes.cljs b/frontend/src/app/main/data/workspace/changes.cljs index d9910e13a..b3ffc2d76 100644 --- a/frontend/src/app/main/data/workspace/changes.cljs +++ b/frontend/src/app/main/data/workspace/changes.cljs @@ -66,10 +66,10 @@ (cond-> changes (not (empty? rops)) - (update :rch conj (assoc change :operations rops)) + (update :redo-changes conj (assoc change :operations rops)) (not (empty? uops)) - (update :uch conj (assoc change :operations uops))))) + (update :undo-changes conj (assoc change :operations uops))))) (defn update-shapes ([ids f] (update-shapes ids f nil)) @@ -82,25 +82,26 @@ (ptk/reify ::update-shapes ptk/WatchEvent (watch [it state stream] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state) - reg-objects {:type :reg-objects :page-id page-id :shapes (vec ids)} + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state) + changes {:redo-changes [] + :undo-changes [] + :origin it + :save-undo? save-undo?} - {redo-changes :rch undo-changes :uch} - (reduce #(update-shape-changes %1 page-id objects f keys %2) - {:rch [] :uch []} ids)] + ids (into [] (filter some?) ids) - (when-not (empty? redo-changes) - (let [redo-changes (cond-> redo-changes - reg-objects? (conj reg-objects)) + changes (reduce #(update-shape-changes %1 page-id objects f keys %2) changes ids)] - undo-changes (cond-> undo-changes - reg-objects? (conj reg-objects))] - - (rx/of (commit-changes {:redo-changes redo-changes - :undo-changes undo-changes - :origin it - :save-undo? save-undo?}))))))))) + (when-not (empty? (:redo-changes changes)) + (let [reg-objs {:type :reg-objects + :page-id page-id + :shapes ids} + changes (cond-> changes + reg-objects? + (-> (update :redo-changes conj reg-objs) + (update :undo-changes conj reg-objs)))] + (rx/of (commit-changes changes))))))))) (defn update-indices [page-id changes] From 053d46144e3b3242ac57777dfb44401556b7d4b4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 3 Jun 2021 17:24:19 +0200 Subject: [PATCH 2/2] :paperclip: Fix linter issues. --- .clj-kondo/config.edn | 5 +++++ .clj-kondo/hooks/export.clj | 11 +++++++++++ .gitignore | 2 ++ backend/src/app/loggers/audit.clj | 2 +- backend/src/app/tasks/file_xlog_gc.clj | 2 +- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .clj-kondo/hooks/export.clj diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index becc05752..7f0a4e788 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -1,7 +1,12 @@ {:lint-as {potok.core/reify clojure.core/reify promesa.core/let clojure.core/let rumext.alpha/defc clojure.core/defn + app.common.data/export clojure.core/def app.db/with-atomic clojure.core/with-open} + + :hooks + {:analyze-call {app.common.data/export hooks.export/export}} + :output {:exclude-files ["data_readers.clj"]} diff --git a/.clj-kondo/hooks/export.clj b/.clj-kondo/hooks/export.clj new file mode 100644 index 000000000..bac6996ca --- /dev/null +++ b/.clj-kondo/hooks/export.clj @@ -0,0 +1,11 @@ +(ns hooks.export + (:require [clj-kondo.hooks-api :as api])) + +(defn export + [{:keys [:node]}] + (let [[_ sname] (:children node) + result (api/list-node + [(api/token-node (symbol "def")) + (api/token-node (symbol (name (:value sname)))) + sname])] + {:node result})) diff --git a/.gitignore b/.gitignore index 4695ea70a..d1cc5a7af 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,8 @@ node_modules /exporter/target /exporter/.shadow-cljs /docker/images/bundle* +/common/.shadow-cljs +/common/target /.clj-kondo/.cache /bundle* /media diff --git a/backend/src/app/loggers/audit.clj b/backend/src/app/loggers/audit.clj index 0a37e86a2..5fd7f29ec 100644 --- a/backend/src/app/loggers/audit.clj +++ b/backend/src/app/loggers/audit.clj @@ -80,7 +80,7 @@ :max-batch-age (* 10 1000) ; 10s :init []})] (a/go-loop [] - (when-let [[type events] (a/