Merge pull request #220 from status-im/bug/new-chat-navigation-#145
fix new chat navigation history
This commit is contained in:
commit
6ee3e53ab0
|
@ -1,6 +1,6 @@
|
||||||
(ns status-im.accounts.login.handlers
|
(ns status-im.accounts.login.handlers
|
||||||
(:require [re-frame.core :refer [register-handler after dispatch]]
|
(:require [re-frame.core :refer [after dispatch]]
|
||||||
[status-im.utils.handlers :as u]
|
[status-im.utils.handlers :refer [register-handler] :as u]
|
||||||
[status-im.utils.logging :as log]
|
[status-im.utils.logging :as log]
|
||||||
[status-im.utils.types :refer [json->clj]]
|
[status-im.utils.types :refer [json->clj]]
|
||||||
[status-im.db :refer [default-view]]
|
[status-im.db :refer [default-view]]
|
||||||
|
@ -56,4 +56,4 @@
|
||||||
(log/debug "Logged in account: ")
|
(log/debug "Logged in account: ")
|
||||||
(if success
|
(if success
|
||||||
(logged-in db address)
|
(logged-in db address)
|
||||||
(dispatch [:set-in [:login :error] error]))))))))
|
(dispatch [:set-in [:login :error] error]))))))))
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
event (keyword (:event message))]
|
event (keyword (:event message))]
|
||||||
(log/debug (str "message from webview: " message))
|
(log/debug (str "message from webview: " message))
|
||||||
(case event
|
(case event
|
||||||
:webview-send-transaction (dispatch [:show-contacts contacts-click-handler])
|
:webview-send-transaction (dispatch [:navigate-to :contact-list contacts-click-handler])
|
||||||
(log/error (str "Unknown event: " event)))))))
|
(log/error (str "Unknown event: " event)))))))
|
||||||
|
|
||||||
(register-handler :send-to-webview-bridge
|
(register-handler :send-to-webview-bridge
|
||||||
|
|
|
@ -60,13 +60,13 @@
|
||||||
[action-button-item
|
[action-button-item
|
||||||
{:title (label :t/new-chat)
|
{:title (label :t/new-chat)
|
||||||
:buttonColor :#9b59b6
|
:buttonColor :#9b59b6
|
||||||
:onPress #(dispatch [:show-group-contacts :people])}
|
:onPress #(dispatch [:navigate-forget :group-contacts :people])}
|
||||||
[ion-icon {:name :md-create
|
[ion-icon {:name :md-create
|
||||||
:style st/create-icon}]]
|
:style st/create-icon}]]
|
||||||
[action-button-item
|
[action-button-item
|
||||||
{:title (label :t/new-group-chat)
|
{:title (label :t/new-group-chat)
|
||||||
:buttonColor :#1abc9c
|
:buttonColor :#1abc9c
|
||||||
:onPress #(dispatch [:show-group-new])}
|
:onPress #(dispatch [:navigate-to :new-group])}
|
||||||
[ion-icon {:name :md-person
|
[ion-icon {:name :md-person
|
||||||
:style st/person-stalker-icon}]]]]
|
:style st/person-stalker-icon}]]]]
|
||||||
[bottom-gradient]])
|
[bottom-gradient]])
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
:handler #(dispatch [:navigate-to :discovery])
|
:handler #(dispatch [:navigate-to :discovery])
|
||||||
:platform-specific platform-specific}]
|
:platform-specific platform-specific}]
|
||||||
[menu-item {:name (label :t/contacts)
|
[menu-item {:name (label :t/contacts)
|
||||||
:handler #(dispatch [:show-contacts])
|
:handler #(dispatch [:navigate-to :contact-list])
|
||||||
:platform-specific platform-specific}]
|
:platform-specific platform-specific}]
|
||||||
[menu-item {:name (label :t/invite-friends)
|
[menu-item {:name (label :t/invite-friends)
|
||||||
:handler (fn []
|
:handler (fn []
|
||||||
|
|
|
@ -9,7 +9,23 @@
|
||||||
[status-im.utils.phone-number :refer [format-phone-number]]
|
[status-im.utils.phone-number :refer [format-phone-number]]
|
||||||
[status-im.utils.handlers :as u]
|
[status-im.utils.handlers :as u]
|
||||||
[status-im.utils.utils :refer [require]]
|
[status-im.utils.utils :refer [require]]
|
||||||
[status-im.utils.logging :as log]))
|
[status-im.utils.logging :as log]
|
||||||
|
[status-im.navigation.handlers :as nav]))
|
||||||
|
|
||||||
|
|
||||||
|
(defmethod nav/preload-data! :group-contacts
|
||||||
|
[db [_ _ group]]
|
||||||
|
(assoc db :contacts-group group))
|
||||||
|
|
||||||
|
(defmethod nav/preload-data! :new-group
|
||||||
|
[db _]
|
||||||
|
(-> db
|
||||||
|
(assoc :new-group #{})
|
||||||
|
(assoc :new-chat-name nil)))
|
||||||
|
|
||||||
|
(defmethod nav/preload-data! :contact-list
|
||||||
|
[db [_ _ click-handler]]
|
||||||
|
(assoc db :contacts-click-handler click-handler))
|
||||||
|
|
||||||
(defn save-contact
|
(defn save-contact
|
||||||
[_ [_ contact]]
|
[_ [_ contact]]
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
(:require-macros [status-im.utils.views :refer [defview]])
|
(:require-macros [status-im.utils.views :refer [defview]])
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[status-im.components.react :refer [view text
|
[status-im.components.react :refer [view
|
||||||
|
text
|
||||||
image
|
image
|
||||||
touchable-highlight
|
touchable-highlight
|
||||||
linear-gradient
|
linear-gradient
|
||||||
|
@ -63,10 +64,11 @@
|
||||||
^{:key contact}
|
^{:key contact}
|
||||||
[contact-extended-view contact nil (click-handler whisper-identity) nil]))
|
[contact-extended-view contact nil (click-handler whisper-identity) nil]))
|
||||||
contacts))]
|
contacts))]
|
||||||
(when (= contacts-limit (count contacts))
|
(when (<= contacts-limit (count contacts))
|
||||||
[view st/show-all
|
[view st/show-all
|
||||||
[touchable-highlight {:on-press #(dispatch [:show-group-contacts group])}
|
[touchable-highlight {:on-press #(dispatch [:navigate-to :group-contacts group])}
|
||||||
[text {:style st/show-all-text} (label :show-all)]]])])
|
[view
|
||||||
|
[text {:style st/show-all-text} (label :t/show-all)]]]])])
|
||||||
|
|
||||||
(defn contact-list [{platform-specific :platform-specific}]
|
(defn contact-list [{platform-specific :platform-specific}]
|
||||||
(let [contacts (subscribe [:get-added-contacts-with-limit contacts-limit])
|
(let [contacts (subscribe [:get-added-contacts-with-limit contacts-limit])
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
|
|
||||||
(defmethod preload-data! :default [db _] db)
|
(defmethod preload-data! :default [db _] db)
|
||||||
|
|
||||||
|
(register-handler :navigate-forget
|
||||||
|
(enrich preload-data!)
|
||||||
|
(fn [db [_ new-view-id]]
|
||||||
|
(assoc db :view-id new-view-id)))
|
||||||
|
|
||||||
(register-handler :navigate-to
|
(register-handler :navigate-to
|
||||||
(enrich preload-data!)
|
(enrich preload-data!)
|
||||||
(fn [{:keys [view-id] :as db} [_ new-view-id]]
|
(fn [{:keys [view-id] :as db} [_ new-view-id]]
|
||||||
|
@ -37,13 +42,16 @@
|
||||||
|
|
||||||
(register-handler :navigate-back
|
(register-handler :navigate-back
|
||||||
(enrich preload-data!)
|
(enrich preload-data!)
|
||||||
(fn [{:keys [navigation-stack] :as db} _]
|
(fn [{:keys [navigation-stack view-id] :as db} _]
|
||||||
(if (>= 1 (count navigation-stack))
|
(if (>= 1 (count navigation-stack))
|
||||||
db
|
db
|
||||||
(let [[view-id :as navigation-stack'] (pop navigation-stack)]
|
(let [[previous-view-id :as navigation-stack'] (pop navigation-stack)
|
||||||
(-> db
|
first-in-stack (first navigation-stack)]
|
||||||
(assoc :view-id view-id)
|
(if (= view-id first-in-stack)
|
||||||
(assoc :navigation-stack navigation-stack'))))))
|
(-> db
|
||||||
|
(assoc :view-id previous-view-id)
|
||||||
|
(assoc :navigation-stack navigation-stack'))
|
||||||
|
(assoc db :view-id first-in-stack))))))
|
||||||
|
|
||||||
(register-handler :navigate-to-tab
|
(register-handler :navigate-to-tab
|
||||||
(enrich preload-data!)
|
(enrich preload-data!)
|
||||||
|
@ -57,30 +65,10 @@
|
||||||
(fn [db [_]]
|
(fn [db [_]]
|
||||||
(assoc db :prev-tab-view-id nil)))
|
(assoc db :prev-tab-view-id nil)))
|
||||||
|
|
||||||
(register-handler :show-group-new
|
|
||||||
(debug
|
|
||||||
(fn [db _]
|
|
||||||
(-> db
|
|
||||||
(push-view :new-group)
|
|
||||||
(assoc :new-group #{})
|
|
||||||
(assoc :new-chat-name nil)))))
|
|
||||||
|
|
||||||
(register-handler :show-contacts
|
|
||||||
(fn [db [_ click-handler]]
|
|
||||||
(-> db
|
|
||||||
(assoc :contacts-click-handler click-handler)
|
|
||||||
(push-view :contact-list))))
|
|
||||||
|
|
||||||
(register-handler :remove-contacts-click-handler
|
(register-handler :remove-contacts-click-handler
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(dissoc db :contacts-click-handler)))
|
(dissoc db :contacts-click-handler)))
|
||||||
|
|
||||||
(register-handler :show-group-contacts
|
|
||||||
(fn [db [_ group]]
|
|
||||||
(-> db
|
|
||||||
(assoc :contacts-group group)
|
|
||||||
(push-view :group-contacts))))
|
|
||||||
|
|
||||||
(defn show-profile
|
(defn show-profile
|
||||||
[db [_ identity]]
|
[db [_ identity]]
|
||||||
(-> db
|
(-> db
|
||||||
|
|
Loading…
Reference in New Issue