Compare commits

...
Author SHA1 Message Date
Ajay Sivan eb6fc05aa1 wip: Sync with QR error messages 2023-06-30 16:11:37 +05:30
6 changed files with 49 additions and 32 deletions
+34 -21
View File
@@ -81,33 +81,46 @@
(merge account {:password password}))
navigate-to-syncing-devices? (and (or connection-success? error-on-pairing?) receiver?)
user-in-syncing-devices-screen? (= (:view-id db) :syncing-progress)]
(merge {:db (cond-> db
connection-success?
(assoc-in [:syncing :pairing-status] :connected)
received-account?
(assoc-in [:syncing :profile/profile] multiaccount-data)
(if error-on-pairing?
(rf/dispatch [:toasts/upsert
{:icon :i/info
:icon-color colors/danger-50
:override-theme :dark
:text (i18n/label (condp = type
constants/local-pairing-event-connection-error
:t/error-this-sync-qr-code-has-expired
constants/local-pairing-event-transfer-error
:t/error-devices-are-not-in-the-same-network
constants/local-pairing-event-process-error
:t/error-this-sync-qr-code-has-been-used-before
:t/error-syncing-connection-failed))}])
(merge {:db (cond-> db
connection-success?
(assoc-in [:syncing :pairing-status] :connected)
received-account?
(assoc-in [:syncing :profile/profile] multiaccount-data)
error-on-pairing?
(assoc-in [:syncing :pairing-status] :error)
error-on-pairing?
(assoc-in [:syncing :pairing-status] :error)
completed-pairing?
(assoc-in [:syncing :pairing-status] :completed))}
(cond
(and navigate-to-syncing-devices? (not user-in-syncing-devices-screen?))
{:dispatch [:navigate-to :syncing-progress]}
completed-pairing?
(assoc-in [:syncing :pairing-status] :completed))}
(cond
(and navigate-to-syncing-devices? (not user-in-syncing-devices-screen?))
{:dispatch [:navigate-to :syncing-progress]}
(and completed-pairing? sender?)
{:dispatch [:syncing/clear-states]}
(and completed-pairing? sender?)
{:dispatch [:syncing/clear-states]}
(and completed-pairing? receiver?)
{:dispatch [:multiaccounts.login/local-paired-user]}
(and completed-pairing? receiver?)
{:dispatch [:multiaccounts.login/local-paired-user]}
(and error-on-pairing? (some? error))
{:dispatch [:toasts/upsert
{:icon :i/alert
:icon-color colors/danger-50
:text error}]}))))
(and error-on-pairing? (some? error))
{:dispatch [:toasts/upsert
{:icon :i/alert
:icon-color colors/danger-50
:text error}]})))))
(rf/defn process
{:events [:signals/signal-received]}
+3
View File
@@ -271,6 +271,9 @@
(def ^:const local-pairing-role-sender "sender")
(def ^:const local-pairing-role-receiver "receiver")
(def ^:const local-pairing-timeout 120000)
(def ^:const local-pairing-timeout-warning 60000)
;; sender and receiver events
(def ^:const local-pairing-event-connection-success "connection-success")
(def ^:const local-pairing-event-connection-error "connection-error")
+1 -1
View File
@@ -88,7 +88,7 @@
:keystorePath ""
:password sha3-pwd
:deviceType utils.platform/os}
:serverConfig {:timeout 0}}))]
:serverConfig {:timeout constants/local-pairing-timeout}}))]
(native-module/get-connection-string-for-bootstrapping-another-device
config-map
#(show-sheet %)))
@@ -232,7 +232,7 @@
(rf/dispatch [:toasts/upsert
{:icon :i/info
:icon-color colors/danger-50
:override-theme :light
:override-theme :dark
:text (i18n/label :t/error-this-is-not-a-sync-qr-code)}]))))
(defn render-camera
@@ -12,10 +12,8 @@
[reagent.core :as reagent]
[status-im2.common.resources :as resources]
[react-native.hooks :as hooks]
[status-im2.contexts.syncing.utils :as sync-utils]))
(def code-valid-for-ms 120000)
(def one-min-ms 60000)
[status-im2.contexts.syncing.utils :as sync-utils]
[status-im2.constants :as constants]))
(defn navigation-bar
[]
@@ -41,7 +39,7 @@
(defn view
[]
(let [valid-for-ms (reagent/atom code-valid-for-ms)
(let [valid-for-ms (reagent/atom constants/local-pairing-timeout)
code (reagent/atom nil)
delay (reagent/atom nil)
timestamp (reagent/atom nil)
@@ -51,11 +49,11 @@
(reset! delay 1000)
(reset! code connection-string)))
clock (fn []
(if (pos? (- code-valid-for-ms
(if (pos? (- constants/local-pairing-timeout
(- (* 1000 (js/Math.ceil (/ (datetime/timestamp) 1000)))
@timestamp)))
(swap! valid-for-ms (fn [_]
(- code-valid-for-ms
(- constants/local-pairing-timeout
(- (* 1000
(js/Math.ceil (/ (datetime/timestamp) 1000)))
@timestamp))))
@@ -63,7 +61,7 @@
cleanup-clock (fn []
(reset! code nil)
(reset! timestamp nil)
(reset! valid-for-ms code-valid-for-ms))]
(reset! valid-for-ms constants/local-pairing-timeout))]
(fn []
[rn/view {:style style/container-main}
@@ -107,7 +105,7 @@
(i18n/label :t/sync-code)]
[quo/text
{:size :paragraph-2
:style {:color (if (< @valid-for-ms one-min-ms)
:style {:color (if (< @valid-for-ms constants/local-pairing-timeout-warning)
colors/danger-60
colors/white-opa-40)}}
(i18n/label :t/valid-for-time {:valid-for (datetime/ms-to-duration @valid-for-ms)})]]
+3
View File
@@ -2108,6 +2108,9 @@
"i-dont-have-status-on-another-device": "I dont have Status on another device",
"ensure-qr-code-is-in-focus-to-scan": "Ensure that the QR code is in focus to scan",
"error-this-is-not-a-sync-qr-code": "Oops! This is not a sync QR code",
"error-this-sync-qr-code-has-expired": "Oops! This sync QR code has expired",
"error-this-sync-qr-code-has-been-used-before": "Oops! This sync QR code has been used before",
"error-devices-are-not-in-the-same-network": "Oops! Devices are not in the same network",
"error-syncing-connection-failed": "Oops! Connection failed. Try again",
"camera-permission-denied": "Permission denied",
"enable-biometrics": "Enable biometrics",