Fix for weird behaviour if back is pressed in 2nd onboarding (#775)
This commit is contained in:
parent
4bd800f5ca
commit
c1abe16f89
|
@ -58,6 +58,7 @@
|
|||
(register-handler :create-account
|
||||
(u/side-effect!
|
||||
(fn [_ [_ password]]
|
||||
(dispatch [:set :creating-account? true])
|
||||
(s/execute-later #(dispatch [:account-generation-message]) 400)
|
||||
(status/create-account
|
||||
password
|
||||
|
|
|
@ -41,10 +41,15 @@
|
|||
;; todo: it might be better always return false from
|
||||
;; this listener and handle application's closing
|
||||
;; in handlers
|
||||
(let [stack (subscribe [:get :navigation-stack])]
|
||||
(when (< 1 (count @stack))
|
||||
(dispatch [:navigate-back])
|
||||
true)))]
|
||||
(let [stack (subscribe [:get :navigation-stack])
|
||||
creating? (subscribe [:get :creating-account?])]
|
||||
(cond
|
||||
@creating? true
|
||||
|
||||
(< 1 (count @stack))
|
||||
(do (dispatch [:navigate-back]) true)
|
||||
|
||||
:else false)))]
|
||||
(.addEventListener back-android "hardwareBackPress" new-listener)))
|
||||
|
||||
(defn orientation->keyword [o]
|
||||
|
|
|
@ -16,3 +16,8 @@
|
|||
(+ input-height suggestions-header-height))
|
||||
|
||||
(def emoji-container-height 250)
|
||||
|
||||
(def crazy-math-message-id "crazy-math-message")
|
||||
(def passphrase-message-id "passphraze-message")
|
||||
(def intro-status-message-id "intro-status")
|
||||
(def intro-message1-id "intro-message1")
|
|
@ -254,13 +254,13 @@
|
|||
(register-handler :account-generation-message
|
||||
(u/side-effect!
|
||||
(fn [_]
|
||||
(when-not (messages/get-by-id sign-up-service/passphraze-message-id)
|
||||
(when-not (messages/get-by-id chat-consts/passphrase-message-id)
|
||||
(sign-up-service/account-generation-message)))))
|
||||
|
||||
(register-handler :show-mnemonic
|
||||
(u/side-effect!
|
||||
(fn [_ [_ mnemonic]]
|
||||
(let [crazy-math-message? (messages/get-by-id sign-up-service/crazy-math-message)]
|
||||
(let [crazy-math-message? (messages/get-by-id chat-consts/crazy-math-message-id)]
|
||||
(sign-up-service/passphrase-messages mnemonic crazy-math-message?)))))
|
||||
|
||||
(register-handler :sign-up
|
||||
|
|
|
@ -28,10 +28,12 @@
|
|||
[status-im.chat.views.bottom-info :refer [bottom-info-view]]
|
||||
[status-im.chat.views.toolbar-content :refer [toolbar-content-view]]
|
||||
[status-im.chat.views.suggestions :refer [suggestion-container]]
|
||||
[status-im.chat.constants :as const]
|
||||
[status-im.i18n :refer [label label-pluralize]]
|
||||
[status-im.components.animation :as anim]
|
||||
[status-im.components.sync-state.offline :refer [offline-view]]
|
||||
[status-im.constants :refer [content-type-status]]))
|
||||
[status-im.constants :refer [content-type-status]]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn contacts-by-identity [contacts]
|
||||
(->> contacts
|
||||
|
@ -109,10 +111,11 @@
|
|||
|
||||
(defview chat-toolbar []
|
||||
[show-actions? [:chat-ui-props :show-actions?]
|
||||
accounts [:get :accounts]]
|
||||
accounts [:get :accounts]
|
||||
creating? [:get :creating-account?]]
|
||||
[view
|
||||
[status-bar]
|
||||
[toolbar {:hide-nav? (or (empty? accounts) show-actions?)
|
||||
[toolbar {:hide-nav? (or (empty? accounts) show-actions? creating?)
|
||||
:custom-content [toolbar-content-view]
|
||||
:custom-action [toolbar-action]
|
||||
:style (get-in platform-specific [:component-styles :toolbar])}]
|
||||
|
@ -121,7 +124,7 @@
|
|||
(defn get-intro-status-message [all-messages]
|
||||
(let [{:keys [timestamp content-type]} (last all-messages)]
|
||||
(when (not= content-type content-type-status)
|
||||
{:message-id "intro-status"
|
||||
{:message-id const/intro-status-message-id
|
||||
:content-type content-type-status
|
||||
:timestamp (or timestamp (time/now-ms))})))
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
content-type-command
|
||||
content-type-command-request
|
||||
content-type-status]]
|
||||
[status-im.chat.constants :as const]
|
||||
[status-im.i18n :refer [label]]
|
||||
[clojure.string :as s]))
|
||||
|
||||
|
@ -110,11 +111,10 @@
|
|||
:from console-chat-id
|
||||
:to "me"}]))
|
||||
|
||||
(def crazy-math-message "crazy-math-message")
|
||||
;; -- Saving password ----------------------------------------
|
||||
(defn account-generation-message []
|
||||
(dispatch [:received-message
|
||||
{:message-id crazy-math-message
|
||||
{:message-id const/crazy-math-message-id
|
||||
:content (label :t/account-generation-message)
|
||||
:content-type text-content-type
|
||||
:outgoing false
|
||||
|
@ -122,11 +122,9 @@
|
|||
:from console-chat-id
|
||||
:to "me"}]))
|
||||
|
||||
(def passphraze-message-id "passphraze-message")
|
||||
|
||||
(defn passphrase-messages [mnemonic crazy-math-message?]
|
||||
(dispatch [:received-message
|
||||
{:message-id passphraze-message-id
|
||||
{:message-id const/passphrase-message-id
|
||||
:content (if crazy-math-message?
|
||||
(label :t/phew-here-is-your-passphrase)
|
||||
(label :t/here-is-your-passphrase))
|
||||
|
@ -146,7 +144,7 @@
|
|||
(start-signup))
|
||||
|
||||
(def intro-status
|
||||
{:message-id "intro-status"
|
||||
{:message-id const/intro-status-message-id
|
||||
:content (label :t/intro-status)
|
||||
:from console-chat-id
|
||||
:chat-id console-chat-id
|
||||
|
@ -159,7 +157,7 @@
|
|||
(dispatch [:received-message-when-commands-loaded
|
||||
console-chat-id
|
||||
{:chat-id console-chat-id
|
||||
:message-id "intro-message1"
|
||||
:message-id const/intro-message1-id
|
||||
:content (command-content
|
||||
:password
|
||||
(label :t/intro-message1))
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
[status-im.chat.constants :as c]
|
||||
[status-im.chat.views.plain-message :as plain-message]
|
||||
[status-im.chat.views.command :as command]
|
||||
[status-im.constants :refer [content-type-status]]
|
||||
[status-im.utils.platform :refer [platform-specific ios?]]))
|
||||
[status-im.constants :refer [content-type-status
|
||||
console-chat-id]]
|
||||
[status-im.utils.platform :refer [platform-specific ios?]]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(register-sub :chat-properties
|
||||
(fn [db [_ properties]]
|
||||
|
|
|
@ -77,10 +77,12 @@
|
|||
show-actions? (subscribe [:chat-ui-props :show-actions?])
|
||||
accounts (subscribe [:get :accounts])
|
||||
contact (subscribe [:get-in [:contacts @chat-id]])
|
||||
sync-state (subscribe [:get :sync-state])]
|
||||
sync-state (subscribe [:get :sync-state])
|
||||
creating? (subscribe [:get :creating-account?])]
|
||||
(fn []
|
||||
[view (st/chat-name-view (or (empty? @accounts)
|
||||
@show-actions?))
|
||||
@show-actions?
|
||||
@creating?))
|
||||
(let [chat-name (if (str/blank? @name)
|
||||
(generate-gfy)
|
||||
(or (get-contact-translated @chat-id :name @name)
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
(dispatch [:init-debug-mode address])
|
||||
(dispatch [:send-account-update-if-needed])
|
||||
(dispatch [:start-requesting-discoveries])
|
||||
(dispatch [:remove-old-discoveries!]))))
|
||||
(dispatch [:remove-old-discoveries!])
|
||||
(dispatch [:set :creating-account? false]))))
|
||||
|
||||
(register-handler :reset-app
|
||||
(u/side-effect!
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns status-im.navigation.handlers
|
||||
(:require [re-frame.core :refer [dispatch debug enrich after]]
|
||||
[status-im.utils.handlers :refer [register-handler]]))
|
||||
(:require [re-frame.core :refer [dispatch subscribe debug enrich after]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.constants :refer [console-chat-id]]))
|
||||
|
||||
(defn push-view [db view-id]
|
||||
(-> db
|
||||
|
@ -50,6 +51,11 @@
|
|||
(fn [db [_ view-id]]
|
||||
(replace-view db view-id)))
|
||||
|
||||
(defn- can-navigate-back? [db]
|
||||
(and (not (db :creating-account?))
|
||||
;; ...
|
||||
))
|
||||
|
||||
(register-handler :navigate-back
|
||||
(enrich -preload-data!)
|
||||
(fn [{:keys [navigation-stack view-id modal] :as db} _]
|
||||
|
@ -59,13 +65,15 @@
|
|||
(>= 1 (count navigation-stack)) db
|
||||
|
||||
:else
|
||||
(if (can-navigate-back? db)
|
||||
(let [[previous-view-id :as navigation-stack'] (pop navigation-stack)
|
||||
first-in-stack (first navigation-stack)]
|
||||
(if (= view-id first-in-stack)
|
||||
(-> db
|
||||
(assoc :view-id previous-view-id)
|
||||
(assoc :navigation-stack navigation-stack'))
|
||||
(assoc db :view-id first-in-stack))))))
|
||||
(assoc db :view-id first-in-stack)))
|
||||
db))))
|
||||
|
||||
(register-handler :navigate-to-tab
|
||||
(enrich preload-data!)
|
||||
|
|
Loading…
Reference in New Issue