diff --git a/common/app/common/geom/point.cljc b/common/app/common/geom/point.cljc index 8ca2bb45bc..0d13aa542a 100644 --- a/common/app/common/geom/point.cljc +++ b/common/app/common/geom/point.cljc @@ -148,14 +148,17 @@ (assert (point? p)) (assert (point? other)) - (let [a (/ (+ (* x ox) - (* y oy)) - (* (length p) - (length other))) - a (mth/acos (if (< a -1) -1 (if (> a 1) 1 a))) - d (-> (mth/degrees a) - (mth/precision 6))] - (if (mth/nan? d) 0 d))) + (if (or (= 0 (length p)) + (= 0 (length other))) + 0 + (let [a (/ (+ (* x ox) + (* y oy)) + (* (length p) + (length other))) + a (mth/acos (if (< a -1) -1 (if (> a 1) 1 a))) + d (-> (mth/degrees a) + (mth/precision 6))] + (if (mth/nan? d) 0 d)))) (defn update-angle diff --git a/common/app/common/pages.cljc b/common/app/common/pages.cljc index 52accc13e0..7b996b8fd6 100644 --- a/common/app/common/pages.cljc +++ b/common/app/common/pages.cljc @@ -20,7 +20,7 @@ [app.common.spec :as us] [app.common.uuid :as uuid])) -(def file-version 3) +(def file-version 4) (def max-safe-int 9007199254740991) (def min-safe-int -9007199254740991) diff --git a/common/app/common/pages_migrations.cljc b/common/app/common/pages_migrations.cljc index 75697f5e37..e36ca0f5b3 100644 --- a/common/app/common/pages_migrations.cljc +++ b/common/app/common/pages_migrations.cljc @@ -109,3 +109,18 @@ (update page :objects #(d/mapm update-object %)))] (update data :pages-index #(d/mapm update-page %)))) + +(defmethod migrate 4 + [data] + (letfn [(update-object [id object] + (cond-> object + (= (:id object) uuid/zero) + (assoc :points [] + :selrect {:x 0 :y 0 + :width 1 :height 1 + :x1 0 :y1 0 + :x2 1 :y2 1}))) + + (update-page [id page] + (update page :objects #(d/mapm update-object %)))] + (update data :pages-index #(d/mapm update-page %))))