diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 12460a6e3..f4aba631f 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -2287,6 +2287,44 @@ (reduce #(update %1 :workspace-preview-blend dissoc %2) state ids)))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Components +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defn find-components-norefs + [] + (ptk/reify ::find-components-norefs + ptk/WatchEvent + (watch [_ state _] + (let [objects (wsh/lookup-page-objects state) + copies (->> objects + vals + (filter #(and (:component-root %) (not (:main-instance %))))) + copies-no-ref (filter #(not (:shape-ref %)) copies) + find-childs-no-ref (fn [acc-map item] + (let [id (:id item) + childs (->> (cph/get-children objects id) + (filter #(not (:shape-ref %))))] + (if (seq childs) + (assoc acc-map id childs) + acc-map))) + childs-no-ref (reduce + find-childs-no-ref + {} + copies)] + (js/console.log "Copies no ref" (clj->js copies-no-ref)) + (js/console.log "Childs no ref" (clj->js childs-no-ref)))))) + +(defn set-shape-ref + [id shape-ref] + (ptk/reify ::set-shape-ref + ptk/WatchEvent + (watch [_ _ _] + (rx/of (update-shape (uuid/uuid id) {:shape-ref (uuid/uuid shape-ref)}))))) + + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Exports ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/frontend/src/debug.cljs b/frontend/src/debug.cljs index ee8f76d87..de9391bdc 100644 --- a/frontend/src/debug.cljs +++ b/frontend/src/debug.cljs @@ -401,3 +401,12 @@ (defn ^:export fix-orphan-shapes [] (st/emit! (dw/fix-orphan-shapes))) + +(defn ^:export find-components-norefs + [] + (st/emit! (dw/find-components-norefs))) + +(defn ^:export set-shape-ref + [id shape-ref] + (st/emit! (dw/set-shape-ref id shape-ref))) +