diff --git a/common/src/app/common/time.cljc b/common/src/app/common/time.cljc index fb5a5d1d1b..755151bcfc 100644 --- a/common/src/app/common/time.cljc +++ b/common/src/app/common/time.cljc @@ -204,40 +204,41 @@ (defn format-inst ([v] (format-inst v :iso)) ([v fmt] - (case fmt - (:iso :iso8601) - #?(:clj (.format DateTimeFormatter/ISO_INSTANT ^Instant v) - :cljs (dfn-format-iso v)) + (when (some? v) + (case fmt + (:iso :iso8601) + #?(:clj (.format DateTimeFormatter/ISO_INSTANT ^Instant v) + :cljs (dfn-format-iso v)) - :iso-date - #?(:clj (.format DateTimeFormatter/ISO_LOCAL_DATE - ^ZonedDateTime (ZonedDateTime/ofInstant v (ZoneId/of "UTC"))) - :cljs (dfn-format-iso v #js {:representation "date"})) + :iso-date + #?(:clj (.format DateTimeFormatter/ISO_LOCAL_DATE + ^ZonedDateTime (ZonedDateTime/ofInstant v (ZoneId/of "UTC"))) + :cljs (dfn-format-iso v #js {:representation "date"})) - (:rfc1123 :http) - #?(:clj (.format DateTimeFormatter/RFC_1123_DATE_TIME - ^ZonedDateTime (ZonedDateTime/ofInstant v (ZoneId/of "UTC"))) - :cljs (dfn-format v "EEE, dd LLL yyyy HH:mm:ss 'GMT'")) + (:rfc1123 :http) + #?(:clj (.format DateTimeFormatter/RFC_1123_DATE_TIME + ^ZonedDateTime (ZonedDateTime/ofInstant v (ZoneId/of "UTC"))) + :cljs (dfn-format v "EEE, dd LLL yyyy HH:mm:ss 'GMT'")) - #?@(:cljs [:time-24-simple - (dfn-format v "HH:mm") + #?@(:cljs [:time-24-simple + (dfn-format v "HH:mm") - ;; DEPRECATED - :date-full - (dfn-format v "PPP") + ;; DEPRECATED + :date-full + (dfn-format v "PPP") - :localized-date - (dfn-format v "PPP") + :localized-date + (dfn-format v "PPP") - :localized-time - (dfn-format v "p") + :localized-time + (dfn-format v "p") - :localized-date-time - (dfn-format v "PPP . p") + :localized-date-time + (dfn-format v "PPP . p") - (if (string? fmt) - (dfn-format v fmt) - (throw (js/Error. "unpexted format")))])))) + (if (string? fmt) + (dfn-format v fmt) + (throw (js/Error. "unpexted format")))]))))) #?(:cljs (def locales diff --git a/frontend/src/app/main/data/workspace/versions.cljs b/frontend/src/app/main/data/workspace/versions.cljs index dd46c3cf16..58e1e52f62 100644 --- a/frontend/src/app/main/data/workspace/versions.cljs +++ b/frontend/src/app/main/data/workspace/versions.cljs @@ -137,16 +137,16 @@ (ptk/reify ::pin-version ptk/WatchEvent (watch [_ state _] - (let [version (->> (dm/get-in state [:workspace-versions :data]) - (d/seek #(= (:id %) id))) - params {:id id - :label (ct/format-inst (:created-at version) :localized-date)}] + (when-let [version (->> (dm/get-in state [:workspace-versions :data]) + (d/seek #(= (:id %) id)))] + (let [params {:id id + :label (ct/format-inst (:created-at version) :localized-date)}] - (->> (rp/cmd! :update-file-snapshot params) - (rx/mapcat (fn [_] - (rx/of (update-versions-state {:editing id}) - (fetch-versions) - (ptk/event ::ev/event {::ev/name "pin-version"}))))))))) + (->> (rp/cmd! :update-file-snapshot params) + (rx/mapcat (fn [_] + (rx/of (update-versions-state {:editing id}) + (fetch-versions) + (ptk/event ::ev/event {::ev/name "pin-version"})))))))))) (defn lock-version [id]