From bec09fb5d1b13d018f01e77ce7c4d5a6ebed96e9 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 25 Jul 2023 12:52:47 +0200 Subject: [PATCH] :sparkles: Improve connection errors handling on workspace save operation --- .../app/main/data/workspace/persistence.cljs | 18 +++++++++++++----- frontend/src/app/main/errors.cljs | 3 ++- frontend/src/app/main/ui.cljs | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index cf74bbf1f..e0b08734b 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -182,11 +182,19 @@ (rx/of (shapes-changes-persisted-finished)))))) (rx/catch (fn [cause] - (rx/concat - (if (= :authentication (:type cause)) - (rx/empty) - (rx/of (rt/assign-exception cause))) - (rx/throw cause))))))))) + (cond + (= :authentication (:type cause)) + (rx/throw cause) + + (instance? js/TypeError cause) + (->> (rx/timer 2000) + (rx/map (fn [_] + (persist-changes file-id file-revn changes pending-commits)))) + + :else + (rx/concat + (rx/of (rt/assign-exception cause)) + (rx/throw cause)))))))))) ;; Event to be thrown after the changes have been persisted (defn shapes-changes-persisted-finished diff --git a/frontend/src/app/main/errors.cljs b/frontend/src/app/main/errors.cljs index ea60fa7b8..7bd072645 100644 --- a/frontend/src/app/main/errors.cljs +++ b/frontend/src/app/main/errors.cljs @@ -66,7 +66,8 @@ (defmethod ptk/handle-error :default [error] - (ts/schedule #(st/emit! (rt/assign-exception (::instance error)))) + (when-let [cause (::instance error)] + (ts/schedule #(st/emit! (rt/assign-exception cause)))) (print-group! "Unhandled Error" (fn [] (print-trace! error) diff --git a/frontend/src/app/main/ui.cljs b/frontend/src/app/main/ui.cljs index 7528fdcd3..93c848be8 100644 --- a/frontend/src/app/main/ui.cljs +++ b/frontend/src/app/main/ui.cljs @@ -142,6 +142,7 @@ (mf/with-effect [theme] (dom/set-html-theme-color theme)) + [:& (mf/provider ctx/current-route) {:value route} [:& (mf/provider ctx/current-profile) {:value profile} (if edata