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