Make some small fixes

This commit is contained in:
Andrés Moya 2020-10-15 11:15:35 +02:00
parent 68ca44188c
commit a6d47cca10
4 changed files with 34 additions and 22 deletions

View file

@ -58,7 +58,7 @@
(defn get-object-with-children (defn get-object-with-children
"Retrieve a list with an object and all of its children" "Retrieve a list with an object and all of its children"
[id objects] [id objects]
(map #(get objects %) (d/concat [id] (get-children id objects)))) (map #(get objects %) (cons id (get-children id objects))))
(defn is-shape-grouped (defn is-shape-grouped
"Checks if a shape is inside a group" "Checks if a shape is inside a group"

View file

@ -364,7 +364,8 @@
(ptk/reify ::reset-component (ptk/reify ::reset-component
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(js/console.info "##### RESET-COMPONENT of shape" (str id)) ;; ===== Uncomment this to debug =====
;; (js/console.info "##### RESET-COMPONENT of shape" (str id))
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
page (get-in state [:workspace-data :pages-index page-id]) page (get-in state [:workspace-data :pages-index page-id])
objects (dwc/lookup-page-objects state page-id) objects (dwc/lookup-page-objects state page-id)
@ -377,10 +378,11 @@
state state
true) true)
_ (js/console.info "shape" (:name shape) "<- component" (:name component)) ;; ===== Uncomment this to debug =====
_ (js/console.debug "all-shapes" (clj->js all-shapes)) ;; _ (js/console.info "shape" (:name shape) "<- component" (:name component))
_ (js/console.debug "component" (clj->js component)) ;; _ (js/console.debug "all-shapes" (clj->js all-shapes))
_ (js/console.debug "root-component" (clj->js root-component)) ;; _ (js/console.debug "component" (clj->js component))
;; _ (js/console.debug "root-component" (clj->js root-component))
[rchanges uchanges] [rchanges uchanges]
(dwlh/generate-sync-shape-and-children-components shape (dwlh/generate-sync-shape-and-children-components shape
@ -391,7 +393,8 @@
nil nil
true)] true)]
(js/console.debug "rchanges" (clj->js rchanges)) ;; ===== Uncomment this to debug =====
;; (js/console.debug "rchanges" (clj->js rchanges))
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})))))) (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))
@ -401,7 +404,8 @@
(ptk/reify ::update-component (ptk/reify ::update-component
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(js/console.info "##### UPDATE-COMPONENT of shape" (str id)) ;; ===== Uncomment this to debug =====
;; (js/console.info "##### UPDATE-COMPONENT of shape" (str id))
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (dwc/lookup-page-objects state page-id) objects (dwc/lookup-page-objects state page-id)
shape (get objects id) shape (get objects id)
@ -413,10 +417,11 @@
state state
true) true)
_ (js/console.info "shape" (:name shape) "-> component" (:name component)) ;; ===== Uncomment this to debug =====
_ (js/console.debug "all-shapes" (clj->js all-shapes)) ;; _ (js/console.info "shape" (:name shape) "-> component" (:name component))
_ (js/console.debug "component" (clj->js component)) ;; _ (js/console.debug "all-shapes" (clj->js all-shapes))
_ (js/console.debug "root-component" (clj->js root-component)) ;; _ (js/console.debug "component" (clj->js component))
;; _ (js/console.debug "root-component" (clj->js root-component))
[rchanges uchanges] [rchanges uchanges]
(dwlh/generate-sync-shape-inverse shape (dwlh/generate-sync-shape-inverse shape
@ -425,7 +430,8 @@
root-component root-component
page-id)] page-id)]
(js/console.debug "rchanges" (clj->js rchanges)) ;; ===== Uncomment this to debug =====
;; (js/console.debug "rchanges" (clj->js rchanges))
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})))))) (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))
@ -443,7 +449,8 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(js/console.info "##### SYNC-FILE" (str (or file-id "local"))) ;; ===== Uncomment this to debug =====
;; (js/console.info "##### SYNC-FILE" (str (or file-id "local")))
(let [[rchanges1 uchanges1] (dwlh/generate-sync-file :components file-id state) (let [[rchanges1 uchanges1] (dwlh/generate-sync-file :components file-id state)
[rchanges2 uchanges2] (dwlh/generate-sync-library :components file-id state) [rchanges2 uchanges2] (dwlh/generate-sync-library :components file-id state)
[rchanges3 uchanges3] (dwlh/generate-sync-file :colors file-id state) [rchanges3 uchanges3] (dwlh/generate-sync-file :colors file-id state)
@ -452,7 +459,8 @@
[rchanges6 uchanges6] (dwlh/generate-sync-library :typographies file-id state) [rchanges6 uchanges6] (dwlh/generate-sync-library :typographies file-id state)
rchanges (d/concat rchanges1 rchanges2 rchanges3 rchanges4 rchanges5 rchanges6) rchanges (d/concat rchanges1 rchanges2 rchanges3 rchanges4 rchanges5 rchanges6)
uchanges (d/concat uchanges1 uchanges2 uchanges3 uchanges4 uchanges5 uchanges6)] uchanges (d/concat uchanges1 uchanges2 uchanges3 uchanges4 uchanges5 uchanges6)]
(js/console.debug "rchanges" (clj->js rchanges)) ;; ===== Uncomment this to debug =====
;; (js/console.debug "rchanges" (clj->js rchanges))
(rx/concat (rx/concat
(rx/of (dm/hide-tag :sync-dialog)) (rx/of (dm/hide-tag :sync-dialog))
(when rchanges (when rchanges
@ -478,13 +486,15 @@
(ptk/reify ::sync-file-2nd-stage (ptk/reify ::sync-file-2nd-stage
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(js/console.info "##### SYNC-FILE" (str (or file-id "local")) "(2nd stage)") ;; ===== Uncomment this to debug =====
;; (js/console.info "##### SYNC-FILE" (str (or file-id "local")) "(2nd stage)")
(let [[rchanges1 uchanges1] (dwlh/generate-sync-file :components nil state) (let [[rchanges1 uchanges1] (dwlh/generate-sync-file :components nil state)
[rchanges2 uchanges2] (dwlh/generate-sync-library :components file-id state) [rchanges2 uchanges2] (dwlh/generate-sync-library :components file-id state)
rchanges (d/concat rchanges1 rchanges2) rchanges (d/concat rchanges1 rchanges2)
uchanges (d/concat uchanges1 uchanges2)] uchanges (d/concat uchanges1 uchanges2)]
(when rchanges (when rchanges
(js/console.debug "rchanges" (clj->js rchanges)) ;; ===== Uncomment this to debug =====
;; (js/console.debug "rchanges" (clj->js rchanges))
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))) (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})))))))
(def ignore-sync (def ignore-sync

View file

@ -422,14 +422,17 @@
"Generate changes to synchronize one shape inside a component, with other "Generate changes to synchronize one shape inside a component, with other
shape that is linked to it." shape that is linked to it."
[shape root-shape root-component component page-id] [shape root-shape root-component component page-id]
(js/console.log "component" (clj->js component)) ;; ===== Uncomment this to debug =====
;; (js/console.log "component" (clj->js component))
(if (nil? component) (if (nil? component)
empty-changes empty-changes
(let [component-shape (get (:objects component) (:shape-ref shape))] (let [component-shape (get (:objects component) (:shape-ref shape))]
(js/console.log "component-shape" (clj->js component-shape)) ;; ===== Uncomment this to debug =====
;; (js/console.log "component-shape" (clj->js component-shape))
(if (nil? component-shape) (if (nil? component-shape)
empty-changes empty-changes
(let [_(js/console.info "update" (:name shape) "->" (:name component-shape)) (let [;; ===== Uncomment this to debug =====
;; _(js/console.info "update" (:name shape) "->" (:name component-shape))
[rchanges1 uchanges1] [rchanges1 uchanges1]
(update-attrs component-shape (update-attrs component-shape
shape shape

View file

@ -90,8 +90,7 @@
(let [shape (get objects shape-id)] (let [shape (get objects shape-id)]
(println (str/pad (str (str/repeat " " level) (println (str/pad (str (str/repeat " " level)
(:name shape) (:name shape)
(when (seq (filter #(not= :position-group %) (when (seq (:touched shape)) "*")
(:touched shape))) "*"))
{:length 20 {:length 20
:type :right}) :type :right})
(show-component shape objects)) (show-component shape objects))