diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 1f0d40bb5..a46c02352 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -176,12 +176,12 @@ [:add-color [:map {:title "AddColorChange"} [:type [:= :add-color]] - [:color :any]]] + [:color ::ctc/color]]] [:mod-color [:map {:title "ModColorChange"} [:type [:= :mod-color]] - [:color :any]]] + [:color ::ctc/color]]] [:del-color [:map {:title "DelColorChange"} @@ -608,8 +608,7 @@ (when (and (= object-type :shape) (nil? page-id)) (ex/raise :type :internal :hint "update for shapes needs a page-id")) - (letfn [(update-fn - [data] + (letfn [(update-fn [data] (if (some? value) (assoc-in data [:plugin-data namespace key] value) (update-in data [:plugin-data namespace] (fnil dissoc {}) key)))] diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index ad10599c2..701e2c3a2 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -895,11 +895,11 @@ :description "Satisfies Inst protocol" :error/message "should be an instant" :gen/gen (->> (sg/small-int) - (sg/fmap (fn [v] (tm/instant v)))) + (sg/fmap (fn [v] (tm/parse-instant v)))) - :decode/string tm/instant + :decode/string tm/parse-instant :encode/string tm/format-instant - :decode/json tm/instant + :decode/json tm/parse-instant :encode/json tm/format-instant ::oapi/type "string" ::oapi/format "iso"}}) diff --git a/common/src/app/common/time.cljc b/common/src/app/common/time.cljc index 27ebdf38b..02c41f946 100644 --- a/common/src/app/common/time.cljc +++ b/common/src/app/common/time.cljc @@ -27,11 +27,22 @@ #?(:clj (Instant/now) :cljs (.local ^js DateTime))) -(defn instant +(defn instant? + [o] + #?(:clj (instance? Instant o) + :cljs (instance? DateTime o))) + +(defn parse-instant [s] - (if (int? s) + (cond + (instant? s) + s + + (int? s) #?(:clj (Instant/ofEpochMilli s) :cljs (.fromMillis ^js DateTime s #js {:zone "local" :setZone false})) + + (string? s) #?(:clj (Instant/parse s) :cljs (.fromISO ^js DateTime s))))