From 835e97d672b8a92b15ce90ed1838e1d2a6f78c54 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Wed, 13 Dec 2023 14:40:33 +0300 Subject: [PATCH] [#17518] fix: try again when sync has error outside the onboarding flow (#17890) --- src/status_im2/common/pairing/events.cljs | 5 ++++- .../onboarding/syncing/progress/view.cljs | 17 ++++++++++++----- .../contexts/syncing/scan_sync_code/view.cljs | 17 +++++++++++++---- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/status_im2/common/pairing/events.cljs b/src/status_im2/common/pairing/events.cljs index 114c5ba7fb..0d10e83681 100644 --- a/src/status_im2/common/pairing/events.cljs +++ b/src/status_im2/common/pairing/events.cljs @@ -18,6 +18,8 @@ constants/local-pairing-event-connection-success) (= action constants/local-pairing-action-connect)) + connection-error? (and (= type + constants/local-pairing-event-connection-error)) error-on-pairing? (contains? constants/local-pairing-event-errors type) completed-pairing? (and (= type constants/local-pairing-event-transfer-success) @@ -30,8 +32,9 @@ (and (some? account) (some? password))) multiaccount-data (when received-account? (merge account {:password password})) - navigate-to-syncing-devices? (and (or connection-success? error-on-pairing?) receiver?) + navigate-to-syncing-devices? (and (or connection-success? connection-error?) receiver?) user-in-syncing-devices-screen? (or (= (:view-id db) :syncing-progress) + (= (:view-id db) :profiles) (= (:view-id db) :syncing-progress-intro)) user-in-sign-in-intro-screen? (= (:view-id db) :sign-in-intro)] (merge {:db (cond-> db diff --git a/src/status_im2/contexts/onboarding/syncing/progress/view.cljs b/src/status_im2/contexts/onboarding/syncing/progress/view.cljs index 6df263dd27..83fd956b8a 100644 --- a/src/status_im2/contexts/onboarding/syncing/progress/view.cljs +++ b/src/status_im2/contexts/onboarding/syncing/progress/view.cljs @@ -4,6 +4,7 @@ [react-native.core :as rn] [status-im2.contexts.onboarding.common.background.view :as background] [status-im2.contexts.onboarding.syncing.progress.style :as style] + [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -25,12 +26,17 @@ :description-accessibility-label :progress-screen-sub-title}]) (defn try-again-button - [profile-color in-onboarding?] + [profile-color in-onboarding? logged-in?] [quo/button {:on-press (fn [] (rf/dispatch [:syncing/clear-states]) - (rf/dispatch [:navigate-back-to - (if in-onboarding? :sign-in-intro :sign-in)])) + (cond + logged-in? (rf/dispatch [:navigate-back]) + in-onboarding? (rf/dispatch [:navigate-back-to :sign-in-intro]) + :else (do + (rf/dispatch [:navigate-back]) + (debounce/dispatch-and-chill [:open-modal :sign-in] + 1000)))) :accessibility-label :try-again-later-button :customization-color profile-color :container-style style/try-again-button} @@ -39,7 +45,8 @@ (defn view [in-onboarding?] (let [pairing-status (rf/sub [:pairing/pairing-status]) - profile-color (:color (rf/sub [:onboarding/profile]))] + profile-color (:color (rf/sub [:onboarding/profile])) + logged-in? (rf/sub [:multiaccount/logged-in?])] [rn/view {:style (style/page-container in-onboarding?)} (when-not in-onboarding? [background/view true]) [quo/page-nav {:type :no-title :background :blur}] @@ -50,7 +57,7 @@ [rn/view {:style style/page-illustration} [quo/text "[Error here]"]]) (when-not (pairing-progress pairing-status) - [try-again-button profile-color in-onboarding?])])) + [try-again-button profile-color in-onboarding? logged-in?])])) (defn view-onboarding [] diff --git a/src/status_im2/contexts/syncing/scan_sync_code/view.cljs b/src/status_im2/contexts/syncing/scan_sync_code/view.cljs index 74d36d40c2..642b1d38df 100644 --- a/src/status_im2/contexts/syncing/scan_sync_code/view.cljs +++ b/src/status_im2/contexts/syncing/scan_sync_code/view.cljs @@ -289,14 +289,22 @@ scan-code? (reagent/atom true) set-rescan-timeout (fn [] (reset! scan-code? false) - (js/setTimeout #(reset! scan-code? true) 3000))] + (js/setTimeout (fn [] + (reset! scan-code? true) + (reset! qr-code-succeed? false)) + 3000))] (fn [{:keys [title show-bottom-view? background animated?]}] (let [torch-mode (if @torch? :on :off) flashlight-icon (if @torch? :i/flashlight-on :i/flashlight-off) scan-qr-code-tab? (= @active-tab 1) + view-id (rf/sub [:view-id]) show-camera? (and scan-qr-code-tab? @camera-permission-granted? @preflight-check-passed? + (some #{view-id} + [:sign-in-intro + :sign-in + :scan-sync-code-page]) (boolean (not-empty @qr-view-finder))) camera-ready-to-scan? (and (or (not animated?) @render-camera?) show-camera? @@ -312,8 +320,7 @@ :show-camera? show-camera? :content-opacity content-opacity :subtitle-opacity subtitle-opacity - :title-opacity title-opacity}) - view-id (rf/sub [:view-id])] + :title-opacity title-opacity})] (rn/use-effect #(set-listener-torch-off-on-app-inactive torch?)) @@ -348,7 +355,9 @@ {:torch-mode torch-mode :qr-view-finder @qr-view-finder :scan-code? @scan-code? - :set-qr-code-succeeded #(reset! qr-code-succeed? true) + :set-qr-code-succeeded (fn [] + (reset! qr-code-succeed? true) + (set-rescan-timeout)) :set-rescan-timeout set-rescan-timeout}]) [rn/view {:style (style/root-container (:top insets))} [:f> header