🐛 Fixes problems with previous migration

This commit is contained in:
alonso.torres 2020-11-24 17:13:44 +01:00
parent ef9b0062dd
commit 0fcfd30535
3 changed files with 27 additions and 9 deletions

View file

@ -148,14 +148,17 @@
(assert (point? p)) (assert (point? p))
(assert (point? other)) (assert (point? other))
(let [a (/ (+ (* x ox) (if (or (= 0 (length p))
(* y oy)) (= 0 (length other)))
(* (length p) 0
(length other))) (let [a (/ (+ (* x ox)
a (mth/acos (if (< a -1) -1 (if (> a 1) 1 a))) (* y oy))
d (-> (mth/degrees a) (* (length p)
(mth/precision 6))] (length other)))
(if (mth/nan? d) 0 d))) 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 (defn update-angle

View file

@ -20,7 +20,7 @@
[app.common.spec :as us] [app.common.spec :as us]
[app.common.uuid :as uuid])) [app.common.uuid :as uuid]))
(def file-version 3) (def file-version 4)
(def max-safe-int 9007199254740991) (def max-safe-int 9007199254740991)
(def min-safe-int -9007199254740991) (def min-safe-int -9007199254740991)

View file

@ -109,3 +109,18 @@
(update page :objects #(d/mapm update-object %)))] (update page :objects #(d/mapm update-object %)))]
(update data :pages-index #(d/mapm update-page %)))) (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 %))))