diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 4713efa81..50e8689fd 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -1,6 +1,7 @@ {:lint-as {promesa.core/let clojure.core/let rumext.alpha/defc clojure.core/defn + rumext.alpha/fnc clojure.core/fn app.common.data/export clojure.core/def app.db/with-atomic clojure.core/with-open} @@ -16,6 +17,8 @@ "app/worker/.*" "app/main/ui.*" "app/libs/.*" + "app/main/data/workspace/path/selection.cljs" + "app/main/data/workspace/transforms.cljs" ]} :linters diff --git a/frontend/src/app/main/data/workspace/changes.cljs b/frontend/src/app/main/data/workspace/changes.cljs index b3ffc2d76..f18a87104 100644 --- a/frontend/src/app/main/data/workspace/changes.cljs +++ b/frontend/src/app/main/data/workspace/changes.cljs @@ -10,14 +10,13 @@ [app.common.pages :as cp] [app.common.pages.spec :as spec] [app.common.spec :as us] - [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.state-helpers :as wsh] - [app.main.worker :as uw] + [app.main.data.workspace.undo :as dwu] [app.main.store :as st] + [app.main.worker :as uw] [app.util.logging :as log] [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] [potok.core :as ptk])) ;; Change this to :info :debug or :trace to debug this module @@ -59,29 +58,29 @@ attrs) uops (cond-> uops - (not (empty? uops)) + (seq uops) (conj {:type :set-touched :touched (:touched old-obj)})) change {:type :mod-obj :page-id page-id :id id}] (cond-> changes - (not (empty? rops)) + (seq rops) (update :redo-changes conj (assoc change :operations rops)) - (not (empty? uops)) + (seq uops) (update :undo-changes conj (assoc change :operations uops))))) (defn update-shapes ([ids f] (update-shapes ids f nil)) ([ids f {:keys [reg-objects? save-undo? keys] - :or {reg-objects? false save-undo? true attrs nil}}] + :or {reg-objects? false save-undo? true}}] (us/assert ::coll-of-uuid ids) (us/assert fn? f) (ptk/reify ::update-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state) changes {:redo-changes [] @@ -107,7 +106,7 @@ [page-id changes] (ptk/reify ::update-indices ptk/EffectEvent - (effect [_ state stream] + (effect [_ _ _] (uw/ask! {:cmd :update-page-indices :page-id page-id :changes changes})))) @@ -147,7 +146,7 @@ state)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (when-not @error (let [;; adds page-id to page changes (that have the `id` field instead) add-page-id @@ -163,7 +162,7 @@ (group-by :page-id)) process-page-changes - (fn [[page-id changes]] + (fn [[page-id _changes]] (update-indices page-id redo-changes))] (rx/concat (rx/from (map process-page-changes changes-by-pages)) diff --git a/frontend/src/app/main/data/workspace/colors.cljs b/frontend/src/app/main/data/workspace/colors.cljs index 2e40b5b98..1813fa712 100644 --- a/frontend/src/app/main/data/workspace/colors.cljs +++ b/frontend/src/app/main/data/workspace/colors.cljs @@ -7,23 +7,13 @@ (ns app.main.data.workspace.colors (:require [app.common.data :as d] - [app.common.pages :as cp] - [app.common.spec :as us] - [app.common.uuid :as uuid] [app.main.data.modal :as md] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.texts :as dwt] [app.main.repo :as rp] - [app.main.store :as st] - [app.main.streams :as ms] - [app.util.color :as color] - [app.util.i18n :refer [tr]] - [app.util.router :as rt] - [app.util.time :as dt] [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] [potok.core :as ptk])) (def clear-color-for-rename @@ -38,17 +28,16 @@ [file-id color-id name] (ptk/reify ::rename-color ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation! :rename-color {:id color-id :name name}) (rx/map (partial rename-color-result file-id)))))) (defn rename-color-result - [file-id color] + [_file-id color] (ptk/reify ::rename-color-result ptk/UpdateEvent (update [_ state] - (-> state - (update-in [:workspace-file :colors] #(d/replace-by-id % color)))))) + (update-in state [:workspace-file :colors] #(d/replace-by-id % color))))) (defn change-palette-size [size] @@ -125,7 +114,7 @@ [ids color] (ptk/reify ::change-fill ptk/WatchEvent - (watch [_ state s] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -157,32 +146,29 @@ [ids color] (ptk/reify ::change-stroke ptk/WatchEvent - (watch [_ state s] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) + (watch [_ _ _] + (let [attrs (cond-> {} + (contains? color :color) + (assoc :stroke-color (:color color)) - attrs (cond-> {} - (contains? color :color) - (assoc :stroke-color (:color color)) + (contains? color :id) + (assoc :stroke-color-ref-id (:id color)) - (contains? color :id) - (assoc :stroke-color-ref-id (:id color)) + (contains? color :file-id) + (assoc :stroke-color-ref-file (:file-id color)) - (contains? color :file-id) - (assoc :stroke-color-ref-file (:file-id color)) + (contains? color :gradient) + (assoc :stroke-color-gradient (:gradient color)) - (contains? color :gradient) - (assoc :stroke-color-gradient (:gradient color)) + (contains? color :opacity) + (assoc :stroke-opacity (:opacity color)))] - (contains? color :opacity) - (assoc :stroke-opacity (:opacity color)))] - - (rx/of (dch/update-shapes ids (fn [shape] - (cond-> (d/merge shape attrs) - (= (:stroke-style shape) :none) - (assoc :stroke-style :solid - :stroke-width 1 - :stroke-opacity 1))))))))) + (rx/of (dch/update-shapes ids (fn [shape] + (cond-> (d/merge shape attrs) + (= (:stroke-style shape) :none) + (assoc :stroke-style :solid + :stroke-width 1 + :stroke-opacity 1))))))))) (defn picker-for-selected-shape diff --git a/frontend/src/app/main/data/workspace/comments.cljs b/frontend/src/app/main/data/workspace/comments.cljs index 08f70ed2f..d83b51455 100644 --- a/frontend/src/app/main/data/workspace/comments.cljs +++ b/frontend/src/app/main/data/workspace/comments.cljs @@ -6,19 +6,14 @@ (ns app.main.data.workspace.comments (:require - [app.common.data :as d] - [app.common.exceptions :as ex] [app.common.math :as mth] [app.common.spec :as us] - [app.main.constants :as c] + [app.main.data.comments :as dcm] [app.main.data.workspace :as dw] [app.main.data.workspace.common :as dwc] - [app.main.data.comments :as dcm] - [app.main.store :as st] [app.main.streams :as ms] [app.util.router :as rt] [beicon.core :as rx] - [cljs.spec.alpha :as s] [potok.core :as ptk])) (declare handle-interrupt) @@ -29,7 +24,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::initialize-comments ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stoper (rx/filter #(= ::finalize %) stream)] (rx/merge (rx/of (dcm/retrieve-comment-threads file-id)) @@ -47,8 +42,8 @@ [] (ptk/reify ::handle-interrupt ptk/WatchEvent - (watch [_ state stream] - (let [local (:comments-local state)] + (watch [_ state _] + (let [local (:comments-local state)] (cond (:draft local) (rx/of (dcm/close-thread)) (:open local) (rx/of (dcm/close-thread)) @@ -62,7 +57,7 @@ [position] (ptk/reify ::handle-comment-layer-click ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [local (:comments-local state)] (if (some? (:open local)) (rx/of (dcm/close-thread)) @@ -74,14 +69,13 @@ (rx/of (dcm/create-draft params)))))))) (defn center-to-comment-thread - [{:keys [id position] :as thread}] + [{:keys [position] :as thread}] (us/assert ::dcm/comment-thread thread) (ptk/reify :center-to-comment-thread ptk/UpdateEvent (update [_ state] (update state :workspace-local - (fn [{:keys [vbox vport zoom] :as local}] - (prn "center-to-comment-thread" vbox) + (fn [{:keys [vbox zoom] :as local}] (let [pw (/ 50 zoom) ph (/ 200 zoom) nw (mth/round (- (/ (:width vbox) 2) pw)) @@ -93,11 +87,11 @@ (update local :vbox assoc :x nx :y ny))))))) (defn navigate - [{:keys [project-id file-id page-id] :as thread}] + [thread] (us/assert ::dcm/comment-thread thread) (ptk/reify ::navigate ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [pparams {:project-id (:project-id thread) :file-id (:file-id thread)} qparams {:page-id (:page-id thread)}] diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index 0e313686b..75e9ce724 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -40,15 +40,13 @@ [{:keys [file] :as bundle}] (ptk/reify ::setup-selection-index ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [msg {:cmd :initialize-indices :file-id (:id file) :data (:data file)}] (->> (uw/ask! msg) (rx/map (constantly ::index-initialized))))))) - - ;; --- Common Helpers & Events (defn get-frame-at-point @@ -59,7 +57,7 @@ (defn- extract-numeric-suffix [basename] - (if-let [[match p1 p2] (re-find #"(.*)-([0-9]+)$" basename)] + (if-let [[_ p1 p2] (re-find #"(.*)-([0-9]+)$" basename)] [p1 (+ 1 (d/parse-integer p2))] [basename 1])) @@ -112,7 +110,7 @@ (def undo (ptk/reify ::undo ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [edition (get-in state [:workspace-local :edition]) drawing (get state :workspace-drawing)] ;; Editors handle their own undo's @@ -131,7 +129,7 @@ (def redo (ptk/reify ::redo ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [edition (get-in state [:workspace-local :edition]) drawing (get state :workspace-drawing)] (when-not (or (some? edition) (not-empty drawing)) @@ -180,10 +178,10 @@ (assoc-in state [:workspace-local :selected] ids)) ptk/WatchEvent - (watch [it state stream] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id)] - (rx/of (expand-all-parents ids objects)))))) + (watch [_ state _] + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id)] + (rx/of (expand-all-parents ids objects)))))) (declare clear-edition-mode) @@ -202,12 +200,11 @@ state))) ptk/WatchEvent - (watch [it state stream] - (let [objects (wsh/lookup-page-objects state)] - (->> stream - (rx/filter interrupt?) - (rx/take 1) - (rx/map (constantly clear-edition-mode))))))) + (watch [_ _ stream] + (->> stream + (rx/filter interrupt?) + (rx/take 1) + (rx/map (constantly clear-edition-mode)))))) ;; If these event change modules review /src/app/main/data/workspace/path/undo.cljs (def clear-edition-mode @@ -282,7 +279,7 @@ (us/verify ::shape-attrs attrs) (ptk/reify ::add-shape ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -313,7 +310,7 @@ (defn move-shapes-into-frame [frame-id shapes] (ptk/reify ::move-shapes-into-frame ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false}) @@ -349,7 +346,7 @@ (us/assert ::set-of-uuid ids) (ptk/reify ::delete-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -504,7 +501,7 @@ [type frame-x frame-y data] (ptk/reify ::create-and-add-shape ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [{:keys [width height]} data [vbc-x vbc-y] (viewport-center state) @@ -524,7 +521,7 @@ [image {:keys [x y]}] (ptk/reify ::image-uploaded ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [{:keys [name width height id mtype]} image shape {:name name :width width diff --git a/frontend/src/app/main/data/workspace/drawing.cljs b/frontend/src/app/main/data/workspace/drawing.cljs index 503d6bee9..14ec47a2a 100644 --- a/frontend/src/app/main/data/workspace/drawing.cljs +++ b/frontend/src/app/main/data/workspace/drawing.cljs @@ -7,17 +7,15 @@ (ns app.main.data.workspace.drawing "Drawing interactions." (:require - [beicon.core :as rx] - [potok.core :as ptk] - [app.common.spec :as us] [app.common.pages :as cp] [app.common.uuid :as uuid] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] - [app.main.data.workspace.path :as path] + [app.main.data.workspace.drawing.box :as box] [app.main.data.workspace.drawing.common :as common] [app.main.data.workspace.drawing.curve :as curve] - [app.main.data.workspace.drawing.box :as box])) + [app.main.data.workspace.path :as path] + [beicon.core :as rx] + [potok.core :as ptk])) (declare start-drawing) (declare handle-drawing) @@ -38,7 +36,7 @@ (update :workspace-layout disj :scale-text))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stoper (rx/filter (ptk/type? ::clear-drawing) stream)] (rx/merge (when (= tool :path) @@ -88,16 +86,17 @@ (update-in state [:workspace-drawing :object] merge data))) ptk/WatchEvent - (watch [_ state stream] - (rx/of (case type - :path - (path/handle-new-shape) + (watch [_ _ _] + (rx/of + (case type + :path + (path/handle-new-shape) - :curve - (curve/handle-drawing-curve) + :curve + (curve/handle-drawing-curve) - ;; default - (box/handle-drawing-box)))))) + ;; default + (box/handle-drawing-box)))))) diff --git a/frontend/src/app/main/data/workspace/drawing/box.cljs b/frontend/src/app/main/data/workspace/drawing/box.cljs index d9e3879a7..01632a744 100644 --- a/frontend/src/app/main/data/workspace/drawing/box.cljs +++ b/frontend/src/app/main/data/workspace/drawing/box.cljs @@ -21,7 +21,7 @@ (defn truncate-zero [num default] (if (mth/almost-zero? num) default num)) -(defn resize-shape [{:keys [x y width height transform transform-inverse] :as shape} point lock?] +(defn resize-shape [{:keys [x y width height] :as shape} point lock?] (let [;; The new shape behaves like a resize on the bottom-right corner initial (gpt/point (+ x width) (+ y height)) shapev (gpt/point width height) @@ -53,9 +53,7 @@ (ptk/reify ::handle-drawing-box ptk/WatchEvent (watch [_ state stream] - (let [{:keys [flags]} (:workspace-local state) - - stoper? #(or (ms/mouse-up? %) (= % :interrupt)) + (let [stoper? #(or (ms/mouse-up? %) (= % :interrupt)) stoper (rx/filter stoper? stream) initial @ms/mouse-position diff --git a/frontend/src/app/main/data/workspace/drawing/common.cljs b/frontend/src/app/main/data/workspace/drawing/common.cljs index 92db09960..fb93c6f5c 100644 --- a/frontend/src/app/main/data/workspace/drawing/common.cljs +++ b/frontend/src/app/main/data/workspace/drawing/common.cljs @@ -6,15 +6,13 @@ (ns app.main.data.workspace.drawing.common (:require - [beicon.core :as rx] - [potok.core :as ptk] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] [app.main.data.workspace.undo :as dwu] - [app.main.streams :as ms] - [app.main.worker :as uw])) + [app.main.worker :as uw] + [beicon.core :as rx] + [potok.core :as ptk])) (def clear-drawing (ptk/reify ::clear-drawing @@ -25,7 +23,7 @@ (def handle-finish-drawing (ptk/reify ::handle-finish-drawing ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [shape (get-in state [:workspace-drawing :object])] (rx/concat (when (:initialized? shape) diff --git a/frontend/src/app/main/data/workspace/drawing/curve.cljs b/frontend/src/app/main/data/workspace/drawing/curve.cljs index 333404214..463c1e9ea 100644 --- a/frontend/src/app/main/data/workspace/drawing/curve.cljs +++ b/frontend/src/app/main/data/workspace/drawing/curve.cljs @@ -6,7 +6,6 @@ (ns app.main.data.workspace.drawing.curve (:require - [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.geom.shapes.path :as gsp] [app.common.pages :as cp] @@ -19,7 +18,7 @@ (def simplify-tolerance 0.3) -(defn stoper-event? [{:keys [type shift] :as event}] +(defn stoper-event? [{:keys [type] :as event}] (ms/mouse-event? event) (= type :up)) (defn initialize-drawing [state] @@ -73,9 +72,8 @@ (defn handle-drawing-curve [] (ptk/reify ::handle-drawing-curve ptk/WatchEvent - (watch [_ state stream] - (let [{:keys [flags]} (:workspace-local state) - stoper (rx/filter stoper-event? stream) + (watch [_ _ stream] + (let [stoper (rx/filter stoper-event? stream) mouse (rx/sample 10 ms/mouse-position)] (rx/concat (rx/of initialize-drawing) diff --git a/frontend/src/app/main/data/workspace/grid.cljs b/frontend/src/app/main/data/workspace/grid.cljs index e405c2364..b04b99f6a 100644 --- a/frontend/src/app/main/data/workspace/grid.cljs +++ b/frontend/src/app/main/data/workspace/grid.cljs @@ -6,11 +6,11 @@ (ns app.main.data.workspace.grid (:require - [beicon.core :as rx] - [potok.core :as ptk] [app.common.data :as d] [app.common.spec :as us] - [app.main.data.workspace.changes :as dch])) + [app.main.data.workspace.changes :as dch] + [beicon.core :as rx] + [potok.core :as ptk])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Grid @@ -40,7 +40,7 @@ (us/assert ::us/uuid frame-id) (ptk/reify ::add-frame-grid ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [page-id (:current-page-id state) data (get-in state [:workspace-data :pages-index page-id]) params (or (get-in data [:options :saved-grids :square]) @@ -56,21 +56,21 @@ [frame-id index] (ptk/reify ::set-frame-grid ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (dch/update-shapes [frame-id] (fn [o] (update o :grids (fnil #(d/remove-at-index % index) [])))))))) (defn set-frame-grid [frame-id index data] (ptk/reify ::set-frame-grid ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (dch/update-shapes [frame-id] #(assoc-in % [:grids index] data)))))) (defn set-default-grid [type params] (ptk/reify ::set-default-grid ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [pid (:current-page-id state) prev-value (get-in state [:workspace-data :pages-index pid :options :saved-grids type])] (rx/of (dch/commit-changes diff --git a/frontend/src/app/main/data/workspace/groups.cljs b/frontend/src/app/main/data/workspace/groups.cljs index 849fdde94..fc88141b3 100644 --- a/frontend/src/app/main/data/workspace/groups.cljs +++ b/frontend/src/app/main/data/workspace/groups.cljs @@ -1,3 +1,9 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + (ns app.main.data.workspace.groups (:require [app.common.data :as d] @@ -5,7 +11,6 @@ [app.common.pages :as cp] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] [app.main.data.workspace.state-helpers :as wsh] [beicon.core :as rx] [potok.core :as ptk])) @@ -22,7 +27,6 @@ [shapes prefix keep-name] (let [selrect (gsh/selection-rect shapes) frame-id (-> shapes first :frame-id) - parent-id (-> shapes first :parent-id) group-name (if (and keep-name (= (count shapes) 1) (= (:type (first shapes)) :group)) @@ -166,7 +170,7 @@ (def group-selected (ptk/reify ::group-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -183,7 +187,7 @@ (def ungroup-selected (ptk/reify ::ungroup-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -200,7 +204,7 @@ (def mask-group (ptk/reify ::mask-group ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -257,7 +261,7 @@ (def unmask-group (ptk/reify ::unmask-group ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state)] diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index f4f177274..7996e492a 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -46,7 +46,7 @@ (:component-id change) :objects (:id change)]) - :default nil)) + :else nil)) prefix (if (:component-id change) "[C] " "[P] ") @@ -90,7 +90,7 @@ (us/assert ::cp/color color) (ptk/reify ::add-color ptk/WatchEvent - (watch [it state s] + (watch [it _ _] (let [rchg {:type :add-color :color color} uchg {:type :del-color @@ -104,7 +104,7 @@ (us/assert ::cp/recent-color color) (ptk/reify ::add-recent-color ptk/WatchEvent - (watch [it state s] + (watch [it _ _] (let [rchg {:type :add-recent-color :color color}] (rx/of (dch/commit-changes {:redo-changes [rchg] @@ -123,7 +123,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::update-color ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [[path name] (cp/parse-path-name (:name color)) color (assoc color :path path :name name) prev (get-in state [:workspace-data :colors id]) @@ -141,7 +141,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-color ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [prev (get-in state [:workspace-data :colors id]) rchg {:type :del-color :id id} @@ -156,7 +156,7 @@ (us/assert ::cp/media-object media) (ptk/reify ::add-media ptk/WatchEvent - (watch [it state stream] + (watch [it _ _] (let [obj (select-keys media [:id :name :width :height :mtype]) rchg {:type :add-media :object obj} @@ -172,7 +172,7 @@ (us/assert ::us/string new-name) (ptk/reify ::rename-media ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [object (get-in state [:workspace-data :media id]) [path name] (cp/parse-path-name new-name) @@ -195,7 +195,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-media ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [prev (get-in state [:workspace-data :media id]) rchg {:type :del-media :id id} @@ -212,7 +212,7 @@ (us/assert ::cp/typography typography) (ptk/reify ::add-typography ptk/WatchEvent - (watch [it state s] + (watch [it _ _] (let [rchg {:type :add-typography :typography typography} uchg {:type :del-typography @@ -230,7 +230,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::update-typography ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [[path name] (cp/parse-path-name (:name typography)) typography (assoc typography :path path :name name) prev (get-in state [:workspace-data :typographies (:id typography)]) @@ -248,7 +248,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-typography ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [prev (get-in state [:workspace-data :typographies id]) rchg {:type :del-typography :id id} @@ -262,7 +262,7 @@ "Add a new component to current file library, from the currently selected shapes." (ptk/reify ::add-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [file-id (:current-file-id state) page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -285,7 +285,7 @@ (us/assert ::us/string new-name) (ptk/reify ::rename-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [[path name] (cp/parse-path-name new-name) component (get-in state [:workspace-data :components id]) objects (get component :objects) @@ -315,7 +315,7 @@ [{:keys [id] :as params}] (ptk/reify ::duplicate-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [component (cp/get-component id (:current-file-id state) (dwlh/get-local-file state) @@ -324,7 +324,7 @@ unames (set (map :name all-components)) new-name (dwc/generate-unique-name unames (:name component)) - [new-shape new-shapes updated-shapes] + [new-shape new-shapes _updated-shapes] (dwlh/duplicate-component component) rchanges [{:type :add-component @@ -346,7 +346,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [component (get-in state [:workspace-data :components id]) rchanges [{:type :del-component @@ -371,7 +371,7 @@ (us/assert ::us/point position) (ptk/reify ::instantiate-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [local-library (dwlh/get-local-file state) libraries (get state :workspace-libraries) component (cp/get-component component-id file-id local-library libraries) @@ -449,7 +449,7 @@ (us/assert ::us/uuid id) (ptk/reify ::detach-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) shapes (cp/get-object-with-children id objects) @@ -511,13 +511,13 @@ (us/assert ::us/uuid file-id) (ptk/reify ::nav-to-component-file ptk/WatchEvent - (watch [it state stream] - (let [file (get-in state [:workspace-libraries file-id]) + (watch [_ state _] + (let [file (get-in state [:workspace-libraries file-id]) pparams {:project-id (:project-id file) :file-id (:id file)} qparams {:page-id (first (get-in file [:data :pages])) :layout :assets}] - (st/emit! (rt/nav-new-window :workspace pparams qparams)))))) + (rx/of (rt/nav-new-window :workspace pparams qparams)))))) (defn ext-library-changed [file-id modified-at revn changes] @@ -540,7 +540,7 @@ (us/assert ::us/uuid id) (ptk/reify ::reset-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "RESET-COMPONENT of shape" :id (str id)) (let [local-library (dwlh/get-local-file state) libraries (dwlh/get-libraries state) @@ -574,7 +574,7 @@ (us/assert ::us/uuid id) (ptk/reify ::update-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "UPDATE-COMPONENT of shape" :id (str id)) (let [page-id (get state :current-page-id) local-library (dwlh/get-local-file state) @@ -642,7 +642,7 @@ state)) ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "SYNC-FILE" :file (dwlh/pretty-file file-id state) :library (dwlh/pretty-file library-id state)) @@ -702,7 +702,7 @@ (us/assert ::us/uuid library-id) (ptk/reify ::sync-file-2nd-stage ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "SYNC-FILE (2nd stage)" :file (dwlh/pretty-file file-id state) :library (dwlh/pretty-file library-id state)) @@ -727,7 +727,7 @@ (assoc-in state [:workspace-file :ignore-sync-until] (dt/now))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (rp/mutation :ignore-sync {:file-id (get-in state [:workspace-file :id]) :date (dt/now)})))) @@ -737,7 +737,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::notify-sync-file ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [libraries-need-sync (filter #(> (:modified-at %) (:synced-at %)) (vals (get state :workspace-libraries))) do-update #(do (apply st/emit! (map (fn [library] diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 738491e7d..7a88d948b 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -90,7 +90,7 @@ (assert (nil? (:shape-ref shape))) (let [;; Ensure that the component root is not an instance and ;; it's no longer tied to a frame. - update-new-shape (fn [new-shape original-shape] + update-new-shape (fn [new-shape _original-shape] (cond-> new-shape true (-> (assoc :frame-id nil) @@ -338,10 +338,10 @@ (defmulti generate-sync-shape "Generate changes to synchronize one shape with all assets of the given type that is using, in the given library." - (fn [type library-id state container shape] type)) + (fn [type _library-id _state _container _shape] type)) (defmethod generate-sync-shape :components - [_ library-id state container shape] + [_ _ state container shape] (generate-sync-shape-direct container (:id shape) (get-local-file state) @@ -666,7 +666,7 @@ [(d/concat rchanges child-rchanges) (d/concat uchanges child-uchanges)])) -(defn- generate-sync-shape-inverse +(defn generate-sync-shape-inverse "Generate changes to update the component a shape is linked to, from the values in the shape and all its children." [page-id shape-id local-library libraries] @@ -886,10 +886,10 @@ set-remote-synced? (assoc :remote-synced? true)))) - update-original-shape (fn [original-shape new-shape] + update-original-shape (fn [original-shape _new-shape] original-shape) - [new-shape new-shapes _] + [_ new-shapes _] (cp/clone-object component-shape (:id parent-shape) (get component :objects) @@ -939,7 +939,7 @@ (cp/get-parents (:id component-parent-shape) (:objects component)))) - update-new-shape (fn [new-shape original-shape] + update-new-shape (fn [new-shape _original-shape] (reposition-shape new-shape root-instance root-main)) @@ -950,7 +950,7 @@ :shape-ref (:id new-shape)) original-shape)) - [new-shape new-shapes updated-shapes] + [_new-shape new-shapes updated-shapes] (cp/clone-object shape (:id component-parent-shape) (get page :objects) @@ -1141,33 +1141,6 @@ :remote-synced? (:remote-synced? shape)}]})]] [rchanges uchanges])))) -(defn- set-touched-shapes-group - [shape container] - (if-not (:shape-ref shape) - empty-changes - (do - (log/info :msg (str "SET-TOUCHED-SHAPES-GROUP " - (if (cp/page? container) "[P] " "[C] ") - (:name shape))) - (let [rchanges [(make-change - container - {:type :mod-obj - :id (:id shape) - :operations - [{:type :set-touched - :touched (cp/set-touched-group - (:touched shape) - :shapes-group)}]})] - - uchanges [(make-change - container - {:type :mod-obj - :id (:id shape) - :operations - [{:type :set-touched - :touched (:touched shape)}]})]] - [rchanges uchanges])))) - (defn- update-attrs "The main function that implements the attribute sync algorithm. Copy attributes that have changed in the origin shape to the dest shape. diff --git a/frontend/src/app/main/data/workspace/notifications.cljs b/frontend/src/app/main/data/workspace/notifications.cljs index 49c7d1387..93dcf9229 100644 --- a/frontend/src/app/main/data/workspace/notifications.cljs +++ b/frontend/src/app/main/data/workspace/notifications.cljs @@ -16,11 +16,7 @@ [app.main.data.workspace.changes :as dch] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.persistence :as dwp] - [app.main.repo :as rp] - [app.main.store :as st] [app.main.streams :as ms] - [app.util.avatars :as avatars] - [app.util.i18n :as i18n :refer [tr]] [app.util.time :as dt] [app.util.websockets :as ws] [beicon.core :as rx] @@ -104,7 +100,7 @@ [file-id] (ptk/reify ::send-keepalive ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (when-let [ws (get-in state [:ws file-id])] (ws/send! ws {:type :keepalive}))))) @@ -112,9 +108,8 @@ [file-id point] (ptk/reify ::handle-pointer-update ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (let [ws (get-in state [:ws file-id]) - sid (:session-id state) pid (:current-page-id state) msg {:type :pointer-update :page-id pid @@ -128,7 +123,7 @@ [file-id] (ptk/reify ::finalize ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when-let [ws (get-in state [:ws file-id])] (ws/-close ws)) (rx/of ::finalize)))) @@ -187,7 +182,7 @@ (update state :workspace-presence update-presence)))))) (defn handle-pointer-update - [{:keys [page-id profile-id session-id x y] :as msg}] + [{:keys [page-id session-id x y] :as msg}] (ptk/reify ::handle-pointer-update ptk/UpdateEvent (update [_ state] @@ -213,7 +208,7 @@ (us/assert ::file-change-event msg) (ptk/reify ::handle-file-change ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [changes-by-pages (group-by :page-id changes) process-page-changes (fn [[page-id changes]] @@ -239,7 +234,7 @@ (us/assert ::library-change-event msg) (ptk/reify ::handle-library-change ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when (contains? (:workspace-libraries state) file-id) (rx/of (dwl/ext-library-changed file-id modified-at revn changes) (dwl/notify-sync-file file-id)))))) diff --git a/frontend/src/app/main/data/workspace/path/changes.cljs b/frontend/src/app/main/data/workspace/path/changes.cljs index cddf0a849..c22fc25e0 100644 --- a/frontend/src/app/main/data/workspace/path/changes.cljs +++ b/frontend/src/app/main/data/workspace/path/changes.cljs @@ -84,7 +84,7 @@ (assoc-in state (st/get-path state :content) content))) ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [objects (wsh/lookup-page-objects state) page-id (:current-page-id state) id (get-in state [:workspace-local :edition]) diff --git a/frontend/src/app/main/data/workspace/path/common.cljs b/frontend/src/app/main/data/workspace/path/common.cljs index d8e6e19cb..f9313126d 100644 --- a/frontend/src/app/main/data/workspace/path/common.cljs +++ b/frontend/src/app/main/data/workspace/path/common.cljs @@ -16,7 +16,8 @@ [state] (dissoc state :last-point :prev-handler :drag-handler :preview)) -(defn finish-path [source] +(defn finish-path + [_source] (ptk/reify ::finish-path ptk/UpdateEvent (update [_ state] diff --git a/frontend/src/app/main/data/workspace/path/drawing.cljs b/frontend/src/app/main/data/workspace/path/drawing.cljs index 75c2f2202..287dd61f0 100644 --- a/frontend/src/app/main/data/workspace/path/drawing.cljs +++ b/frontend/src/app/main/data/workspace/path/drawing.cljs @@ -17,7 +17,6 @@ [app.main.data.workspace.path.spec :as spec] [app.main.data.workspace.path.state :as st] [app.main.data.workspace.path.streams :as streams] - [app.main.data.workspace.path.tools :as tools] [app.main.data.workspace.path.undo :as undo] [app.main.data.workspace.state-helpers :as wsh] [app.main.streams :as ms] @@ -60,9 +59,8 @@ state))))) (defn drag-handler - ([{:keys [x y alt? shift?] :as position}] + ([position] (drag-handler nil nil :c1 position)) - ([position index prefix {:keys [x y alt? shift?]}] (ptk/reify ::drag-handler ptk/UpdateEvent @@ -110,7 +108,7 @@ (update-in (st/get-path state) helpers/update-selrect)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [id (st/get-path-id state) handler (get-in state [:workspace-local :edit-path id :prev-handler])] ;; Update the preview because can be outdated after the dragging @@ -124,9 +122,6 @@ ptk/WatchEvent (watch [_ state stream] (let [id (st/get-path-id state) - zoom (get-in state [:workspace-local :zoom]) - start-position @ms/mouse-position - stop-stream (->> stream (rx/filter #(or (helpers/end-path-event? %) (ms/mouse-up? %)))) @@ -166,9 +161,7 @@ (ptk/reify ::start-path-from-point ptk/WatchEvent (watch [_ state stream] - (let [start-point @ms/mouse-position - zoom (get-in state [:workspace-local :zoom]) - mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %) + (let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %) (ms/mouse-up? %)))) content (get-in state (st/get-path state :content)) points (upg/content->points content) @@ -195,7 +188,7 @@ (rx/merge-map #(rx/empty)))) (defn make-drag-stream - [stream snap-toggled zoom points down-event] + [stream snap-toggled _zoom points down-event] (let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %) (ms/mouse-up? %)))) @@ -211,7 +204,7 @@ (rx/of (finish-drag))))))) (defn handle-drawing-path - [id] + [_id] (ptk/reify ::handle-drawing-path ptk/UpdateEvent (update [_ state] @@ -278,11 +271,11 @@ state))) ptk/WatchEvent - (watch [_ state stream] - (->> (rx/of (setup-frame-path) - dwdc/handle-finish-drawing - (dwc/start-edition-mode shape-id) - (change-edit-mode :draw)))))) + (watch [_ _ _] + (rx/of (setup-frame-path) + dwdc/handle-finish-drawing + (dwc/start-edition-mode shape-id) + (change-edit-mode :draw))))) (defn handle-new-shape "Creates a new path shape" @@ -333,7 +326,7 @@ (defn check-changed-content [] (ptk/reify ::check-changed-content ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [id (st/get-path-id state) content (get-in state (st/get-path state :content)) old-content (get-in state [:workspace-local :edit-path id :old-content]) @@ -354,7 +347,7 @@ id (assoc-in [:workspace-local :edit-path id :edit-mode] mode)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [id (st/get-path-id state)] (cond (and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode")) diff --git a/frontend/src/app/main/data/workspace/path/edition.cljs b/frontend/src/app/main/data/workspace/path/edition.cljs index 4a93e57dd..2005ed10c 100644 --- a/frontend/src/app/main/data/workspace/path/edition.cljs +++ b/frontend/src/app/main/data/workspace/path/edition.cljs @@ -8,11 +8,9 @@ (:require [app.common.data :as d] [app.common.geom.point :as gpt] - [app.common.math :as mth] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] + [app.main.data.workspace.common :as dwc] [app.main.data.workspace.path.changes :as changes] - [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.drawing :as drawing] [app.main.data.workspace.path.helpers :as helpers] [app.main.data.workspace.path.selection :as selection] @@ -47,7 +45,7 @@ (defn apply-content-modifiers [] (ptk/reify ::apply-content-modifiers ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [objects (wsh/lookup-page-objects state) id (st/get-path-id state) @@ -137,7 +135,7 @@ [position shift?] (ptk/reify ::start-move-path-point ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [id (get-in state [:workspace-local :edition]) selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{}) selected? (contains? selected-points position)] @@ -151,7 +149,7 @@ [start-position] (ptk/reify ::drag-selected-points ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [stopper (->> stream (rx/filter ms/mouse-up?)) id (get-in state [:workspace-local :edition]) snap-toggled (get-in state [:workspace-local :edit-path id :snap-toggled]) @@ -206,7 +204,7 @@ state))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [id (get-in state [:workspace-local :edition]) current-move (get-in state [:workspace-local :edit-path id :current-move])] (if (= same-event current-move) @@ -240,7 +238,7 @@ [index prefix] (ptk/reify ::start-move-handler ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [id (get-in state [:workspace-local :edition]) cx (d/prefix-keyword prefix :x) cy (d/prefix-keyword prefix :y) @@ -297,7 +295,7 @@ (assoc-in [:workspace-local :edit-path id :edit-mode] :draw)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [mode (get-in state [:workspace-local :edit-path id :edit-mode])] (rx/concat (rx/of (undo/start-path-undo)) @@ -327,5 +325,5 @@ (update-in (st/get-path state :content) upt/split-segments #{from-p to-p} t)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (changes/save-path-content {:preserve-move-to true}))))) diff --git a/frontend/src/app/main/data/workspace/path/helpers.cljs b/frontend/src/app/main/data/workspace/path/helpers.cljs index cbf9d383c..deff63dce 100644 --- a/frontend/src/app/main/data/workspace/path/helpers.cljs +++ b/frontend/src/app/main/data/workspace/path/helpers.cljs @@ -6,25 +6,23 @@ (ns app.main.data.workspace.path.helpers (:require - [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.math :as mth] [app.main.data.workspace.path.common :as common] - [app.main.data.workspace.path.state :refer [get-path]] [app.main.streams :as ms] [app.util.path.commands :as upc] [app.util.path.subpaths :as ups] [potok.core :as ptk])) -(defn end-path-event? [{:keys [type shift] :as event}] +(defn end-path-event? [event] (or (= (ptk/type event) ::common/finish-path) (= (ptk/type event) :esc-pressed) (= :app.main.data.workspace.common/clear-edition-mode (ptk/type event)) (= :app.main.data.workspace/finalize-page (ptk/type event)) (= event :interrupt) ;; ESC - (and (ms/mouse-double-click? event)))) + (ms/mouse-double-click? event))) (defn content-center [content] @@ -35,7 +33,6 @@ (defn content->points+selrect "Given the content of a shape, calculate its points and selrect" [shape content] - (let [{:keys [flip-x flip-y]} shape transform (cond-> (:transform shape (gmt/matrix)) diff --git a/frontend/src/app/main/data/workspace/path/shortcuts.cljs b/frontend/src/app/main/data/workspace/path/shortcuts.cljs index b88ee5268..55dbcd592 100644 --- a/frontend/src/app/main/data/workspace/path/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/path/shortcuts.cljs @@ -22,7 +22,7 @@ (defn esc-pressed [] (ptk/reify :esc-pressed ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] ;; Not interrupt when we're editing a path (let [edition-id (or (get-in state [:workspace-drawing :object :id]) (get-in state [:workspace-local :edition])) diff --git a/frontend/src/app/main/data/workspace/path/spec.cljs b/frontend/src/app/main/data/workspace/path/spec.cljs index 96ad24fa0..434a97117 100644 --- a/frontend/src/app/main/data/workspace/path/spec.cljs +++ b/frontend/src/app/main/data/workspace/path/spec.cljs @@ -40,8 +40,8 @@ (s/def ::content-entry (s/keys :req-un [::command] - :req-opt [::params - ::relative?])) + :opt-un [::params + ::relative?])) (s/def ::content (s/coll-of ::content-entry :kind vector?)) diff --git a/frontend/src/app/main/data/workspace/path/streams.cljs b/frontend/src/app/main/data/workspace/path/streams.cljs index f8059c483..94c03259e 100644 --- a/frontend/src/app/main/data/workspace/path/streams.cljs +++ b/frontend/src/app/main/data/workspace/path/streams.cljs @@ -6,17 +6,16 @@ (ns app.main.data.workspace.path.streams (:require - [app.main.data.workspace.path.helpers :as helpers] - [app.main.data.workspace.path.state :as state] [app.common.geom.point :as gpt] + [app.common.math :as mth] + [app.main.data.workspace.path.state :as state] + [app.main.snap :as snap] [app.main.store :as st] [app.main.streams :as ms] + [app.util.path.geom :as upg] [beicon.core :as rx] - [potok.core :as ptk] - [app.common.math :as mth] - [app.main.snap :as snap] [okulary.core :as l] - [app.util.path.geom :as upg])) + [potok.core :as ptk])) (defonce drag-threshold 5) @@ -50,7 +49,7 @@ (if (= value ::empty) not-drag-stream (rx/empty))))) - + (->> position-stream (rx/merge-map (fn [] to-stream))))))) @@ -107,7 +106,7 @@ (<= (- 180 rot-angle) 5))] (cond - snap-opposite-angle? + snap-opposite-angle? (let [rot-handler (gpt/rotate handler node (- 180 (* rot-sign rot-angle))) snap (gpt/to-vec handler rot-handler)] (merge position (gpt/add position snap))) @@ -122,7 +121,7 @@ (rx/map check-path-snap)))) (defn position-stream - [snap-toggled points] + [snap-toggled _points] (let [zoom (get-in @st/state [:workspace-local :zoom] 1) ;; ranges (snap/create-ranges points) d-pos (/ snap/snap-path-accuracy zoom) diff --git a/frontend/src/app/main/data/workspace/path/tools.cljs b/frontend/src/app/main/data/workspace/path/tools.cljs index 610897cd2..d13fbf7f7 100644 --- a/frontend/src/app/main/data/workspace/path/tools.cljs +++ b/frontend/src/app/main/data/workspace/path/tools.cljs @@ -6,11 +6,9 @@ (ns app.main.data.workspace.path.tools (:require - [app.common.geom.point :as gpt] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.common :as dwc] [app.main.data.workspace.path.changes :as changes] - [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.state :as st] [app.main.data.workspace.state-helpers :as wsh] [app.util.path.subpaths :as ups] @@ -25,7 +23,7 @@ ([points tool-fn] (ptk/reify ::process-path-tool ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [objects (wsh/lookup-page-objects state) id (st/get-path-id state) page-id (:current-page-id state) @@ -33,7 +31,7 @@ selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{}) points (or points selected-points)] - (when (and (not (empty? points)) (some? shape)) + (when (and (seq points) (some? shape)) (let [new-content (-> (tool-fn (:content shape) points) (ups/close-subpaths)) [rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)] diff --git a/frontend/src/app/main/data/workspace/path/undo.cljs b/frontend/src/app/main/data/workspace/path/undo.cljs index 74c8fcb34..8472d5c88 100644 --- a/frontend/src/app/main/data/workspace/path/undo.cljs +++ b/frontend/src/app/main/data/workspace/path/undo.cljs @@ -9,8 +9,8 @@ [app.common.data :as d] [app.common.data.undo-stack :as u] [app.common.uuid :as uuid] - [app.main.data.workspace.path.state :as st] [app.main.data.workspace.path.changes :as changes] + [app.main.data.workspace.path.state :as st] [app.main.store :as store] [beicon.core :as rx] [okulary.core :as l] @@ -64,7 +64,7 @@ undo-stack))))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/of (changes/save-path-content {:preserve-move-to true}))))) (defn redo-path [] @@ -82,7 +82,7 @@ undo-stack)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/of (changes/save-path-content))))) (defn merge-head @@ -92,10 +92,9 @@ (ptk/reify ::add-undo-entry ptk/UpdateEvent (update [_ state] - (let [id (st/get-path-id state) - entry (make-entry state) + (let [id (st/get-path-id state) stack (get-in state [:workspace-local :edit-path id :undo-stack]) - head (u/peek stack) + head (u/peek stack) stack (-> stack (u/undo) (u/fixup head))] (-> state (d/assoc-in-when @@ -145,7 +144,7 @@ assoc :undo-lock lock :undo-stack (u/make-stack))))) - + ptk/WatchEvent (watch [_ state stream] (let [undo-lock (get-in state [:workspace-local :edit-path (st/get-path-id state) :undo-lock])] diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index 59af222a0..76609c41a 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -8,8 +8,6 @@ (:require [app.common.data :as d] [app.common.exceptions :as ex] - [app.common.geom.point :as gpt] - [app.common.media :as cm] [app.common.pages :as cp] [app.common.spec :as us] [app.common.uuid :as uuid] @@ -26,11 +24,9 @@ [app.main.refs :as refs] [app.main.repo :as rp] [app.main.store :as st] - [app.util.avatars :as avatars] [app.util.http :as http] [app.util.i18n :as i18n :refer [tr]] [app.util.object :as obj] - [app.util.router :as rt] [app.util.time :as dt] [app.util.uri :as uu] [beicon.core :as rx] @@ -52,7 +48,7 @@ [file-id] (ptk/reify ::initialize-persistence ptk/EffectEvent - (effect [_ state stream] + (effect [_ _ stream] (let [stoper (rx/filter #(= ::finalize %) stream) forcer (rx/filter #(= ::force-persist %) stream) notifier (->> stream @@ -120,12 +116,11 @@ (ptk/reify ::persist-changes ptk/UpdateEvent (update [_ state] - (let [conj (fnil conj []) - into* (fnil into [])] + (let [into* (fnil into [])] (update-in state [:workspace-persistence :queue] into* changes))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [sid (:session-id state) file (get state :workspace-file) queue (get-in state [:workspace-persistence :queue] []) @@ -176,7 +171,7 @@ (us/verify ::us/uuid file-id) (ptk/reify ::persist-synchronous-changes ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [sid (:session-id state) file (get-in state [:workspace-libraries file-id]) @@ -259,7 +254,7 @@ [project-id file-id] (ptk/reify ::fetch-bundle ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (->> (rx/zip (rp/query :file {:id file-id}) (rp/query :team-users {:file-id file-id}) (rp/query :project {:id project-id}) @@ -285,7 +280,7 @@ (assoc-in state [:workspace-file :is-shared] is-shared)) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [params {:id id :is-shared is-shared}] (->> (rp/mutation :set-file-shared params) (rx/ignore)))))) @@ -300,7 +295,7 @@ (us/assert ::us/uuid team-id) (ptk/reify ::fetch-shared-files ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (->> (rp/query :team-shared-files {:team-id team-id}) (rx/map shared-files-fetched))))) @@ -320,7 +315,7 @@ [file-id library-id] (ptk/reify ::link-file-to-library ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [fetched #(assoc-in %2 [:workspace-libraries (:id %1)] %1) params {:file-id file-id :library-id library-id}] @@ -332,7 +327,7 @@ [file-id library-id] (ptk/reify ::unlink-file-from-library ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [unlinked #(d/dissoc-in % [:workspace-libraries library-id]) params {:file-id file-id :library-id library-id}] @@ -348,7 +343,7 @@ (->> (rx/of (-> (tubax/xml->clj text) (assoc :name name)))) - (catch :default err + (catch :default _err (rx/throw {:type :svg-parser})))) (defn fetch-svg [name uri] @@ -458,7 +453,7 @@ (s/def ::process-media-objects (s/and (s/keys :req-un [::file-id ::local?] - :opt-in [::name ::data ::uris ::mtype]) + :opt-un [::name ::data ::uris ::mtype]) (fn [props] (or (contains? props :blobs) (contains? props :uris))))) @@ -468,7 +463,7 @@ (us/assert ::process-media-objects params) (ptk/reify ::process-media-objects ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/concat (rx/of (dm/show {:content (tr "media.loading") :type :info @@ -515,7 +510,7 @@ (us/assert ::clone-media-objects-params params) (ptk/reify ::clone-media-objects ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error identity}} (meta params) @@ -548,7 +543,7 @@ [ids] (ptk/reify ::remove-thumbnails ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] ;; Removes the thumbnail while it's regenerated (rx/of (dch/update-shapes ids diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 52d36ee35..fe72eafe2 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -61,7 +61,7 @@ :height (mth/abs (- end-y start-y))}))] (ptk/reify ::handle-selection ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stop? (fn [event] (or (dwc/interrupt? event) (ms/mouse-up? event))) stoper (->> stream (rx/filter stop?))] (rx/concat @@ -100,7 +100,7 @@ (conj selected id)))))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id)] (rx/of (dwc/expand-all-parents [id] objects))))))) @@ -136,7 +136,7 @@ (assoc-in state [:workspace-local :selected] ids)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [objects (wsh/lookup-page-objects state)] (rx/of (dwc/expand-all-parents ids objects)))))) @@ -144,7 +144,7 @@ [] (ptk/reify ::select-all ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) new-selected (let [selected-objs @@ -204,7 +204,7 @@ [preserve?] (ptk/reify ::select-shapes-by-current-selrect ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state) selected (wsh/lookup-selected state) @@ -224,25 +224,23 @@ (rx/map select-shapes)))))))) (defn select-inside-group - ([group-id position] (select-inside-group group-id position false)) - ([group-id position deep-children] - (ptk/reify ::select-inside-group - ptk/WatchEvent - (watch [_ state stream] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) - group (get objects group-id) - children (map #(get objects %) (:shapes group)) + [group-id position] + (ptk/reify ::select-inside-group + ptk/WatchEvent + (watch [_ state _] + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) + group (get objects group-id) + children (map #(get objects %) (:shapes group)) - ;; We need to reverse the children because if two children - ;; overlap we want to select the one that's over (and it's - ;; in the later vector position - selected (->> children - reverse + ;; We need to reverse the children because if two children + ;; overlap we want to select the one that's over (and it's + ;; in the later vector position + selected (->> children + reverse (d/seek #(geom/has-point? % position)))] - (when selected - (rx/of (select-shape (:id selected))))))))) - + (when selected + (rx/of (select-shape (:id selected)))))))) ;; --- Duplicate Shapes (declare prepare-duplicate-change) @@ -321,7 +319,6 @@ name (dwc/generate-unique-name names (:name obj)) renamed-obj (assoc obj :id id :name name) moved-obj (geom/move renamed-obj delta) - frames (cp/select-frames objects) parent-id (or parent-id frame-id) children-changes @@ -378,7 +375,7 @@ (def duplicate-selected (ptk/reify ::duplicate-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs index 7d2fe9bf4..9d8ce9618 100644 --- a/frontend/src/app/main/data/workspace/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/shortcuts.cljs @@ -10,14 +10,13 @@ [app.main.data.workspace :as dw] [app.main.data.workspace.colors :as mdc] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.drawing :as dwd] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.texts :as dwtxt] [app.main.data.workspace.transforms :as dwt] + [app.main.data.workspace.undo :as dwu] [app.main.store :as st] - [app.util.dom :as dom] - [potok.core :as ptk])) + [app.util.dom :as dom])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Shortcuts diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index f2828eb3f..048e4bb96 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -9,7 +9,6 @@ [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] - [app.common.geom.proportions :as gpr] [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.common.uuid :as uuid] @@ -18,14 +17,12 @@ [app.main.data.workspace.state-helpers :as wsh] [app.main.repo :as rp] [app.util.color :as uc] - [app.util.object :as obj] [app.util.path.parser :as upp] [app.util.svg :as usvg] [app.util.uri :as uu] [beicon.core :as rx] [cuerdas.core :as str] - [potok.core :as ptk] - [promesa.core :as p])) + [potok.core :as ptk])) (defonce default-rect {:x 0 :y 0 :width 1 :height 1 :rx 0 :ry 0}) (defonce default-circle {:r 0 :cx 0 :cy 0}) @@ -163,7 +160,7 @@ (gsh/setup-selrect)))) (defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}] - (when (and (contains? attrs :d) (not (empty? (:d attrs)) )) + (when (and (contains? attrs :d) (seq (:d attrs))) (let [svg-transform (usvg/parse-transform (:transform attrs)) path-content (upp/parse-path (:d attrs)) content (cond-> path-content @@ -387,7 +384,7 @@ [svg-data file-id position] (ptk/reify ::svg-uploaded ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] ;; Once the SVG is uploaded, we need to extract all the bitmap ;; images and upload them separatelly, then proceed to create ;; all shapes. @@ -414,7 +411,7 @@ [svg-data {:keys [x y] :as position}] (ptk/reify ::create-svg-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (try (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index f789a50ff..d76abc46b 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -16,17 +16,11 @@ [app.main.data.workspace.common :as dwc] [app.main.data.workspace.selection :as dws] [app.main.data.workspace.state-helpers :as wsh] - [app.main.data.workspace.transforms :as dwt] [app.main.data.workspace.undo :as dwu] - [app.main.fonts :as fonts] - [app.util.object :as obj] + [app.util.router :as rt] [app.util.text-editor :as ted] [app.util.timers :as ts] - [app.util.router :as rt] [beicon.core :as rx] - [cljs.spec.alpha :as s] - [cuerdas.core :as str] - [goog.object :as gobj] [potok.core :as ptk])) (defn update-editor @@ -42,7 +36,7 @@ [] (ptk/reify ::focus-editor ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (when-let [editor (:workspace-editor state)] (ts/schedule #(.focus ^js editor)))))) @@ -59,7 +53,7 @@ [{:keys [id] :as shape}] (ptk/reify ::finalize-editor-state ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [content (-> (get-in state [:workspace-editor-state id]) (ted/get-editor-current-content))] @@ -88,7 +82,7 @@ decorator)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] ;; We need to finalize editor on two main events: (1) when user ;; explicitly navigates to other section or page; (2) when user ;; leaves the editor. @@ -149,7 +143,7 @@ [{:keys [id attrs]}] (ptk/reify ::update-root-attrs ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [objects (wsh/lookup-page-objects state) shape (get objects id) @@ -168,7 +162,7 @@ (d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-block-data attrs)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when-not (some? (get-in state [:workspace-editor-state id])) (let [objects (wsh/lookup-page-objects state) shape (get objects id) @@ -195,7 +189,7 @@ (d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-inline-styles attrs)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when-not (some? (get-in state [:workspace-editor-state id])) (let [objects (wsh/lookup-page-objects state) shape (get objects id) @@ -232,7 +226,7 @@ (defn resize-text-batch [changes] (ptk/reify ::resize-text-batch ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (get-in state [:workspace-data :pages-index page-id :objects])] (if-not (every? #(contains? objects(first %)) changes) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 8f3955b10..643831771 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -11,7 +11,6 @@ [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] - [app.common.math :as mth] [app.common.pages :as cp] [app.common.spec :as us] [app.main.data.workspace.changes :as dch] @@ -19,13 +18,10 @@ [app.main.data.workspace.selection :as dws] [app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.undo :as dwu] - [app.main.refs :as refs] [app.main.snap :as snap] - [app.main.store :as st] [app.main.streams :as ms] [app.util.path.shapes-to-path :as ups] [beicon.core :as rx] - [beicon.core :as rx] [cljs.spec.alpha :as s] [potok.core :as ptk])) diff --git a/frontend/src/app/main/data/workspace/undo.cljs b/frontend/src/app/main/data/workspace/undo.cljs index a63225870..85651e0d8 100644 --- a/frontend/src/app/main/data/workspace/undo.cljs +++ b/frontend/src/app/main/data/workspace/undo.cljs @@ -6,21 +6,10 @@ (ns app.main.data.workspace.undo (:require - [app.common.data :as d] - [app.common.geom.proportions :as gpr] - [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.common.pages.spec :as spec] [app.common.spec :as us] - [app.common.uuid :as uuid] - [app.main.worker :as uw] - [app.main.streams :as ms] - [app.util.logging :as log] - [app.util.timers :as ts] - [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] - [cuerdas.core :as str] [potok.core :as ptk])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -42,7 +31,7 @@ (subvec undo (- cnt MAX-UNDO-SIZE)) undo))) -(defn- materialize-undo +(defn materialize-undo [changes index] (ptk/reify ::materialize-undo ptk/UpdateEvent @@ -51,15 +40,6 @@ (update :workspace-data cp/process-changes changes) (assoc-in [:workspace-undo :index] index))))) -(defn- reset-undo - [index] - (ptk/reify ::reset-undo - ptk/UpdateEvent - (update [_ state] - (-> state - (update :workspace-undo dissoc :undo-index) - (update-in [:workspace-undo :items] (fn [queue] (into [] (take (inc index) queue)))))))) - (defn- add-undo-entry [state entry] (if (and entry @@ -81,7 +61,7 @@ (update-in [:workspace-undo :transaction :undo-changes] #(into undo-changes %)) (update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes)))) -(defn- append-undo +(defn append-undo [entry] (us/assert ::undo-entry entry) (ptk/reify ::append-undo diff --git a/frontend/src/app/main/exports.cljs b/frontend/src/app/main/exports.cljs index cb5a327d5..f3ae1e818 100644 --- a/frontend/src/app/main/exports.cljs +++ b/frontend/src/app/main/exports.cljs @@ -17,7 +17,6 @@ [app.main.ui.shapes.circle :as circle] [app.main.ui.shapes.embed :as embed] [app.main.ui.shapes.export :as use] - [app.main.ui.shapes.filters :as filters] [app.main.ui.shapes.frame :as frame] [app.main.ui.shapes.group :as group] [app.main.ui.shapes.image :as image] diff --git a/frontend/src/app/main/fonts.clj b/frontend/src/app/main/fonts.clj index d36810d45..c947cdabb 100644 --- a/frontend/src/app/main/fonts.clj +++ b/frontend/src/app/main/fonts.clj @@ -7,9 +7,9 @@ (ns app.main.fonts "A fonts loading macros." (:require - [cuerdas.core :as str] + [clojure.data.json :as json] [clojure.java.io :as io] - [clojure.data.json :as json])) + [cuerdas.core :as str])) (defn- parse-gfont-variant [variant] diff --git a/frontend/src/app/main/fonts.cljs b/frontend/src/app/main/fonts.cljs index fcdd27ce3..dbd50cde3 100644 --- a/frontend/src/app/main/fonts.cljs +++ b/frontend/src/app/main/fonts.cljs @@ -15,7 +15,6 @@ [app.util.http :as http] [app.util.logging :as log] [app.util.object :as obj] - [app.util.timers :as ts] [beicon.core :as rx] [clojure.set :as set] [cuerdas.core :as str] @@ -104,7 +103,7 @@ [url on-loaded] (let [node (create-link-element url) head (.-head ^js js/document)] - (gev/listenOnce node "load" (fn [event] + (gev/listenOnce node "load" (fn [_] (when (fn? on-loaded) (on-loaded)))) (dom/append-child! head node))) @@ -140,7 +139,7 @@ (str base ":" variants "&display=block"))) (defmethod load-font :google - [{:keys [id family variants ::on-loaded] :as font}] + [{:keys [id ::on-loaded] :as font}] (when (exists? js/window) (log/debug :action "load-font" :font-id id :backend "google") (let [url (generate-gfonts-url font)] @@ -183,11 +182,13 @@ (str/join "\n"))) (defmethod load-font :custom - [{:keys [id family variants ::on-loaded] :as font}] + [{:keys [id ::on-loaded] :as font}] (when (exists? js/window) (js/console.log "[debug:fonts]: loading custom font" id) (let [css (generate-custom-font-css font)] - (add-font-css! css)))) + (add-font-css! css) + (when (fn? on-loaded) + (on-loaded))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; LOAD API diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index bb3f8a5cb..22e9adebe 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -10,11 +10,8 @@ (:require [app.common.data :as d] [app.common.pages :as cp] - [app.common.uuid :as uuid] - [app.main.constants :as c] [app.main.data.workspace.state-helpers :as wsh] [app.main.store :as st] - [beicon.core :as rx] [okulary.core :as l])) ;; ---- Global refs diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 5ba1ef0d3..26e62bacc 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -9,7 +9,6 @@ ["react-dom/server" :as rds] [app.config :as cfg] [app.main.exports :as exports] - [app.main.exports :as svg] [app.main.fonts :as fonts] [app.util.http :as http] [beicon.core :as rx] @@ -31,16 +30,13 @@ [])) (defn populate-images-cache - ([data] - (populate-images-cache data nil)) - - ([data {:keys [resolve-media?] :or {resolve-media? false}}] - (let [images (->> (:objects data) - (vals) - (mapcat get-image-data))] - (->> (rx/from images) - (rx/map #(cfg/resolve-file-media %)) - (rx/flat-map http/fetch-data-uri))))) + [data] + (let [images (->> (:objects data) + (vals) + (mapcat get-image-data))] + (->> (rx/from images) + (rx/map #(cfg/resolve-file-media %)) + (rx/flat-map http/fetch-data-uri)))) (defn populate-fonts-cache [data] (let [texts (->> (:objects data) diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index cd79ddef7..e9df95ee6 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -10,9 +10,7 @@ [app.common.uri :as u] [app.config :as cfg] [app.util.http :as http] - [app.util.time :as dt] - [beicon.core :as rx] - [cuerdas.core :as str])) + [beicon.core :as rx])) (defn handle-response [{:keys [status body] :as response}] @@ -86,7 +84,7 @@ ([id params] (mutation id params))) (defmethod mutation :login-with-oauth - [id {:keys [provider] :as params}] + [_ {:keys [provider] :as params}] (let [uri (u/join base-uri "api/auth/oauth/" (d/name provider)) params (dissoc params :provider)] (->> (http/send! {:method :post :uri uri :query params}) @@ -94,7 +92,7 @@ (rx/mapcat handle-response)))) (defmethod mutation :send-feedback - [id params] + [_ params] (->> (http/send! {:method :post :uri (u/join base-uri "api/feedback") :body (http/transit-data params)}) @@ -102,7 +100,7 @@ (rx/mapcat handle-response))) (defmethod query :export - [id params] + [_ params] (->> (http/send! {:method :post :uri (u/join base-uri "export") :body (http/transit-data params) diff --git a/frontend/src/app/main/snap.cljs b/frontend/src/app/main/snap.cljs index b8e700b6b..0479c81e8 100644 --- a/frontend/src/app/main/snap.cljs +++ b/frontend/src/app/main/snap.cljs @@ -19,24 +19,24 @@ [beicon.core :as rx] [clojure.set :as set])) -(defonce ^:private snap-accuracy 5) -(defonce ^:private snap-path-accuracy 10) -(defonce ^:private snap-distance-accuracy 10) +(def ^:const snap-accuracy 5) +(def ^:const snap-path-accuracy 10) +(def ^:const snap-distance-accuracy 10) (defn- remove-from-snap-points [remove-id?] (fn [query-result] (->> query-result (map (fn [[value data]] [value (remove (comp remove-id? second) data)])) - (filter (fn [[_ data]] (not (empty? data))))))) + (filter (fn [[_ data]] (seq data)))))) (defn- flatten-to-points [query-result] - (mapcat (fn [[v data]] (map (fn [[point _]] point) data)) query-result)) + (mapcat (fn [[_ data]] (map (fn [[point _]] point) data)) query-result)) (defn- calculate-distance [query-result point coord] (->> query-result - (map (fn [[value data]] [(mth/abs (- value (coord point))) [(coord point) value]])))) + (map (fn [[value _]] [(mth/abs (- value (coord point))) [(coord point) value]])))) (defn- get-min-distance-snap [points coord] (fn [query-result] @@ -286,8 +286,9 @@ (fn [matches other] (let [matches (into {} matches) - other (into {} other) - keys (set/union (keys matches) (keys other))] + other (into {} other) + keys (set/union (set (keys matches)) + (set (keys other)))] (into {} (map (fn [key] [key @@ -308,7 +309,7 @@ min-match-coord (fn [matches] - (if (and (seq matches) (not (empty? matches))) + (if (seq matches) (->> matches (reduce get-min)) default))] diff --git a/frontend/src/app/main/store.cljs b/frontend/src/app/main/store.cljs index f4f15b941..4fd743ecd 100644 --- a/frontend/src/app/main/store.cljs +++ b/frontend/src/app/main/store.cljs @@ -75,12 +75,12 @@ (logjs "state" (get-in @state [:workspace-data :pages-index page-id :objects])))) (defn ^:export dump-object [name] - (let [page-id (get @state :current-page-id)] - (let [objects (get-in @state [:workspace-data :pages-index page-id :objects]) - target (or (d/seek (fn [[id shape]] (= name (:name shape))) objects) - (get objects (uuid name)))] - (->> target - (logjs "state"))))) + (let [page-id (get @state :current-page-id) + objects (get-in @state [:workspace-data :pages-index page-id :objects]) + target (or (d/seek (fn [[_ shape]] (= name (:name shape))) objects) + (get objects (uuid name)))] + (->> target + (logjs "state")))) (defn ^:export dump-tree ([] (dump-tree false false)) @@ -89,7 +89,7 @@ (let [page-id (get @state :current-page-id) objects (get-in @state [:workspace-data :pages-index page-id :objects]) components (get-in @state [:workspace-data :components]) - libraries (get-in @state [:workspace-libraries]) + libraries (get @state :workspace-libraries) root (d/seek #(nil? (:parent-id %)) (vals objects))] (letfn [(show-shape [shape-id level objects] diff --git a/frontend/src/app/main/streams.cljs b/frontend/src/app/main/streams.cljs index e71667fd6..15a05e01a 100644 --- a/frontend/src/app/main/streams.cljs +++ b/frontend/src/app/main/streams.cljs @@ -7,12 +7,10 @@ (ns app.main.streams "User interaction events and streams." (:require - [beicon.core :as rx] [app.main.store :as st] - [app.main.refs :as refs] - [app.common.geom.point :as gpt] [app.util.globals :as globals] - [app.util.keyboard :as kbd])) + [app.util.keyboard :as kbd] + [beicon.core :as rx])) ;; --- User Events diff --git a/frontend/src/app/main/worker.cljs b/frontend/src/app/main/worker.cljs index de564536d..c9004a9f0 100644 --- a/frontend/src/app/main/worker.cljs +++ b/frontend/src/app/main/worker.cljs @@ -6,9 +6,7 @@ (ns app.main.worker (:require - [cljs.spec.alpha :as s] [app.config :as cfg] - [app.common.spec :as us] [app.util.worker :as uw])) (defn on-error