diff --git a/src/status_im/accounts/handlers.cljs b/src/status_im/accounts/handlers.cljs index 80b0173626..37e25a8134 100644 --- a/src/status_im/accounts/handlers.cljs +++ b/src/status_im/accounts/handlers.cljs @@ -6,7 +6,6 @@ [status-im.components.status :as status] [status-im.utils.types :refer [json->clj]] [status-im.utils.identicon :refer [identicon]] - [status-im.db :refer [default-view]] [status-im.utils.random :as random] [status-im.i18n :refer [label]] [status-im.constants :refer [content-type-command-request]] diff --git a/src/status_im/accounts/login/handlers.cljs b/src/status_im/accounts/login/handlers.cljs index 6016c64609..2def56bfc1 100644 --- a/src/status_im/accounts/login/handlers.cljs +++ b/src/status_im/accounts/login/handlers.cljs @@ -3,7 +3,6 @@ [status-im.utils.handlers :refer [register-handler] :as u] [taoensso.timbre :as log] [status-im.utils.types :refer [json->clj]] - [status-im.db :refer [default-view]] [status-im.data-store.core :as data-store] [status-im.components.status :as status] [status-im.constants :refer [console-chat-id]])) diff --git a/src/status_im/accounts/views/account.cljs b/src/status_im/accounts/views/account.cljs index 70c6990832..dbe279ec89 100644 --- a/src/status_im/accounts/views/account.cljs +++ b/src/status_im/accounts/views/account.cljs @@ -12,6 +12,7 @@ [status-im.accounts.styles :as st])) (defn on-press [address] + (dispatch [:navigate-to-clean :accounts]) (dispatch [:navigate-to :login address]) (dispatch [:set-in [:login :address] address])) diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index 2b15ef8a6d..7989ca4586 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -78,30 +78,30 @@ (dispatch [:set :keyboard-height 0])))) :render (fn [] - (let [current-view (validate-current-view @view-id @signed-up?)] - (log/debug current-view) - (let [component (case current-view - :discovery main-tabs - :discovery-tag discovery-tag - :discovery-search-results discovery-search-results - :add-participants new-participants - :remove-participants remove-participants - :chat-list main-tabs - :new-group new-group - :group-settings group-settings - :contact-list main-tabs - :group-contacts contact-list - :new-contact new-contact - :qr-scanner qr-scanner - :chat chat - :profile profile - :profile-photo-capture profile-photo-capture - :accounts accounts - :login login - :recover recover - :confirm confirm - :my-profile my-profile)] - [component])))}))) + (when @view-id + (let [current-view (validate-current-view @view-id @signed-up?)] + (let [component (case current-view + :discovery main-tabs + :discovery-tag discovery-tag + :discovery-search-results discovery-search-results + :add-participants new-participants + :remove-participants remove-participants + :chat-list main-tabs + :new-group new-group + :group-settings group-settings + :contact-list main-tabs + :group-contacts contact-list + :new-contact new-contact + :qr-scanner qr-scanner + :chat chat + :profile profile + :profile-photo-capture profile-photo-capture + :accounts accounts + :login login + :recover recover + :confirm confirm + :my-profile my-profile)] + [component]))))}))) (defn init [& [env]] (dispatch-sync [:reset-app]) diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 303e69db4c..0fe9acb988 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -97,10 +97,11 @@ [chat-icon]]])))) (defview chat-toolbar [] - [show-actions [:chat-ui-props :show-actions?]] + [show-actions? [:chat-ui-props :show-actions?] + accounts [:get :accounts]] [view [status-bar] - [toolbar {:hide-nav? show-actions + [toolbar {:hide-nav? (or (empty? accounts) show-actions?) :custom-content [toolbar-content-view] :custom-action [toolbar-action] :style (get-in platform-specific [:component-styles :toolbar])}]]) diff --git a/src/status_im/chat/views/toolbar_content.cljs b/src/status_im/chat/views/toolbar_content.cljs index ea88f1719d..bf8eec45ed 100644 --- a/src/status_im/chat/views/toolbar_content.cljs +++ b/src/status_im/chat/views/toolbar_content.cljs @@ -50,11 +50,13 @@ name contacts chat-id]} (subscribe [:chat-properties [:group-chat :name :contacts :chat-id]]) - show-actions (subscribe [:chat-ui-props :show-actions?]) - contact (subscribe [:get-in [:contacts @chat-id]]) - sync-state (subscribe [:get :sync-state])] + 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])] (fn [] - [view (st/chat-name-view @show-actions) + [view (st/chat-name-view (or (empty? @accounts) + @show-actions?)) [text {:style st/chat-name-text :number-of-lines 1 :font :toolbar-title} diff --git a/src/status_im/chats_list/screen.cljs b/src/status_im/chats_list/screen.cljs index e21b6bed47..e98a45fc5c 100644 --- a/src/status_im/chats_list/screen.cljs +++ b/src/status_im/chats_list/screen.cljs @@ -36,7 +36,7 @@ new-chat? (into [{:image {:source {:uri :icon_add} :style st/toolbar-icon} - :handler #(dispatch [:navigate-forget :group-contacts :people])}]))] + :handler #(dispatch [:navigate-to :group-contacts :people])}]))] [toolbar {:nav-action {:image {:source {:uri :icon_hamburger} :style st/hamburger-icon} :handler open-drawer} @@ -56,7 +56,7 @@ [action-button-item {:title (label :t/new-chat) :buttonColor :#9b59b6 - :onPress #(dispatch [:navigate-forget :group-contacts :people])} + :onPress #(dispatch [:navigate-to :group-contacts :people])} [ion-icon {:name :md-create :style st/create-icon}]] [action-button-item diff --git a/src/status_im/contacts/handlers.cljs b/src/status_im/contacts/handlers.cljs index 4f4d0825eb..9f685dd5b6 100644 --- a/src/status_im/contacts/handlers.cljs +++ b/src/status_im/contacts/handlers.cljs @@ -16,7 +16,9 @@ (defmethod nav/preload-data! :group-contacts [db [_ _ group]] - (assoc db :contacts-group group)) + (if group + (assoc db :contacts-group group) + db)) (defmethod nav/preload-data! :new-group [db _] diff --git a/src/status_im/db.cljs b/src/status_im/db.cljs index 4f6ac879fe..dd58dd0d7d 100644 --- a/src/status_im/db.cljs +++ b/src/status_im/db.cljs @@ -7,8 +7,6 @@ ;; schema of app-db (def schema {:greeting s/Str}) -(def default-view :chat) - ;; initial state of app-db (def app-db {:identity-password "replace-me-with-user-entered-password" :identity "me" @@ -40,8 +38,8 @@ :chat-ui-props {:show-actions? false :show-bottom-info? false} :selected-participants #{} - :view-id default-view - :navigation-stack (list default-view) + :view-id nil + :navigation-stack '() :current-tag nil :qr-codes {} :keyboard-height 0 diff --git a/src/status_im/ios/core.cljs b/src/status_im/ios/core.cljs index 9a3fdc5244..ea0ca04345 100644 --- a/src/status_im/ios/core.cljs +++ b/src/status_im/ios/core.cljs @@ -28,9 +28,16 @@ (defn orientation->keyword [o] (keyword (.toLowerCase o))) +(defn validate-current-view + [current-view signed-up?] + (if (or (contains? #{:login :chat :recover :accounts} current-view) + signed-up?) + current-view + :chat)) + (defn app-root [] - (let [signed-up (subscribe [:signed-up?]) - _ (log/debug "signed up: " @signed-up) + (let [signed-up? (subscribe [:signed-up?]) + _ (log/debug "signed up: " @signed-up?) view-id (subscribe [:get :view-id]) account-id (subscribe [:get :current-account-id]) keyboard-height (subscribe [:get :keyboard-height])] @@ -56,34 +63,28 @@ #(dispatch [:set :keyboard-height 0])))) :render (fn [] - (let [startup-view (if @account-id - (if @signed-up - @view-id - :chat) - (if (contains? #{:login :chat} @view-id) - @view-id - :accounts))] - (log/debug startup-view) - (let [component (case (if true startup-view :chat) - :discovery main-tabs - :discovery-tag discovery-tag - :discovery-search-results discovery-search-results - :add-participants new-participants - :remove-participants remove-participants - :chat-list main-tabs - :new-group new-group - :group-settings group-settings - :contact-list main-tabs - :group-contacts contact-list - :new-contact new-contact - :qr-scanner qr-scanner - :chat chat - :profile profile - :profile-photo-capture profile-photo-capture - :accounts accounts - :login login - :my-profile my-profile)] - [component])))}))) + (when @view-id + (let [current-view (validate-current-view @view-id @signed-up?)] + (let [component (case current-view + :discovery main-tabs + :discovery-tag discovery-tag + :discovery-search-results discovery-search-results + :add-participants new-participants + :remove-participants remove-participants + :chat-list main-tabs + :new-group new-group + :group-settings group-settings + :contact-list main-tabs + :group-contacts contact-list + :new-contact new-contact + :qr-scanner qr-scanner + :chat chat + :profile profile + :profile-photo-capture profile-photo-capture + :accounts accounts + :login login + :my-profile my-profile)] + [component]))))}))) (defn init [] (dispatch-sync [:reset-app]) diff --git a/src/status_im/navigation/handlers.cljs b/src/status_im/navigation/handlers.cljs index 55df2ff4fd..a5966b2515 100644 --- a/src/status_im/navigation/handlers.cljs +++ b/src/status_im/navigation/handlers.cljs @@ -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]])) + [status-im.utils.handlers :refer [register-handler]] + [taoensso.timbre :as log])) (defn push-view [db view-id] (-> db