[#17518] fix: try again when sync has error outside the onboarding flow (#17890)

This commit is contained in:
Mohsen 2023-12-13 14:40:33 +03:00 committed by GitHub
parent 406904025d
commit 835e97d672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 10 deletions

View File

@ -18,6 +18,8 @@
constants/local-pairing-event-connection-success) constants/local-pairing-event-connection-success)
(= action (= action
constants/local-pairing-action-connect)) 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) error-on-pairing? (contains? constants/local-pairing-event-errors type)
completed-pairing? (and (= type completed-pairing? (and (= type
constants/local-pairing-event-transfer-success) constants/local-pairing-event-transfer-success)
@ -30,8 +32,9 @@
(and (some? account) (some? password))) (and (some? account) (some? password)))
multiaccount-data (when received-account? multiaccount-data (when received-account?
(merge account {:password password})) (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) user-in-syncing-devices-screen? (or (= (:view-id db) :syncing-progress)
(= (:view-id db) :profiles)
(= (:view-id db) :syncing-progress-intro)) (= (:view-id db) :syncing-progress-intro))
user-in-sign-in-intro-screen? (= (:view-id db) :sign-in-intro)] user-in-sign-in-intro-screen? (= (:view-id db) :sign-in-intro)]
(merge {:db (cond-> db (merge {:db (cond-> db

View File

@ -4,6 +4,7 @@
[react-native.core :as rn] [react-native.core :as rn]
[status-im2.contexts.onboarding.common.background.view :as background] [status-im2.contexts.onboarding.common.background.view :as background]
[status-im2.contexts.onboarding.syncing.progress.style :as style] [status-im2.contexts.onboarding.syncing.progress.style :as style]
[utils.debounce :as debounce]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -25,12 +26,17 @@
:description-accessibility-label :progress-screen-sub-title}]) :description-accessibility-label :progress-screen-sub-title}])
(defn try-again-button (defn try-again-button
[profile-color in-onboarding?] [profile-color in-onboarding? logged-in?]
[quo/button [quo/button
{:on-press (fn [] {:on-press (fn []
(rf/dispatch [:syncing/clear-states]) (rf/dispatch [:syncing/clear-states])
(rf/dispatch [:navigate-back-to (cond
(if in-onboarding? :sign-in-intro :sign-in)])) 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 :accessibility-label :try-again-later-button
:customization-color profile-color :customization-color profile-color
:container-style style/try-again-button} :container-style style/try-again-button}
@ -39,7 +45,8 @@
(defn view (defn view
[in-onboarding?] [in-onboarding?]
(let [pairing-status (rf/sub [:pairing/pairing-status]) (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?)} [rn/view {:style (style/page-container in-onboarding?)}
(when-not in-onboarding? [background/view true]) (when-not in-onboarding? [background/view true])
[quo/page-nav {:type :no-title :background :blur}] [quo/page-nav {:type :no-title :background :blur}]
@ -50,7 +57,7 @@
[rn/view {:style style/page-illustration} [rn/view {:style style/page-illustration}
[quo/text "[Error here]"]]) [quo/text "[Error here]"]])
(when-not (pairing-progress pairing-status) (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 (defn view-onboarding
[] []

View File

@ -289,14 +289,22 @@
scan-code? (reagent/atom true) scan-code? (reagent/atom true)
set-rescan-timeout (fn [] set-rescan-timeout (fn []
(reset! scan-code? false) (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?]}] (fn [{:keys [title show-bottom-view? background animated?]}]
(let [torch-mode (if @torch? :on :off) (let [torch-mode (if @torch? :on :off)
flashlight-icon (if @torch? :i/flashlight-on :i/flashlight-off) flashlight-icon (if @torch? :i/flashlight-on :i/flashlight-off)
scan-qr-code-tab? (= @active-tab 1) scan-qr-code-tab? (= @active-tab 1)
view-id (rf/sub [:view-id])
show-camera? (and scan-qr-code-tab? show-camera? (and scan-qr-code-tab?
@camera-permission-granted? @camera-permission-granted?
@preflight-check-passed? @preflight-check-passed?
(some #{view-id}
[:sign-in-intro
:sign-in
:scan-sync-code-page])
(boolean (not-empty @qr-view-finder))) (boolean (not-empty @qr-view-finder)))
camera-ready-to-scan? (and (or (not animated?) @render-camera?) camera-ready-to-scan? (and (or (not animated?) @render-camera?)
show-camera? show-camera?
@ -312,8 +320,7 @@
:show-camera? show-camera? :show-camera? show-camera?
:content-opacity content-opacity :content-opacity content-opacity
:subtitle-opacity subtitle-opacity :subtitle-opacity subtitle-opacity
:title-opacity title-opacity}) :title-opacity title-opacity})]
view-id (rf/sub [:view-id])]
(rn/use-effect (rn/use-effect
#(set-listener-torch-off-on-app-inactive torch?)) #(set-listener-torch-off-on-app-inactive torch?))
@ -348,7 +355,9 @@
{:torch-mode torch-mode {:torch-mode torch-mode
:qr-view-finder @qr-view-finder :qr-view-finder @qr-view-finder
:scan-code? @scan-code? :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}]) :set-rescan-timeout set-rescan-timeout}])
[rn/view {:style (style/root-container (:top insets))} [rn/view {:style (style/root-container (:top insets))}
[:f> header [:f> header