disable 'create button' until new chat will be opened

This commit is contained in:
Roman Volosovskyi 2016-05-19 19:29:17 +03:00
parent 9f5c3df150
commit 6e52fca420
3 changed files with 43 additions and 23 deletions

View File

@ -27,7 +27,8 @@
:phone-number "3147984309" :phone-number "3147984309"
:email "myemail@gmail.com" :email "myemail@gmail.com"
:status "Hi, this is my status" :status "Hi, this is my status"
:current-tag nil}) :current-tag nil
:disable-group-creation false})
(def protocol-initialized-path [:protocol-initialized]) (def protocol-initialized-path [:protocol-initialized])
(defn chat-input-text-path [chat-id] (defn chat-input-text-path [chat-id]

View File

@ -58,12 +58,29 @@
[{:keys [new-group-id]} _] [{:keys [new-group-id]} _]
(dispatch [:show-chat new-group-id :replace])) (dispatch [:show-chat new-group-id :replace]))
(defn enable-creat-buttion
[db _]
(assoc db :disable-group-creation false))
(register-handler :create-new-group (register-handler :create-new-group
(-> start-group-chat! (-> start-group-chat!
((enrich prepare-chat)) ((enrich prepare-chat))
((enrich add-chat)) ((enrich add-chat))
((after create-chat!)) ((after create-chat!))
((after show-chat!)))) ((after show-chat!))
((enrich enable-creat-buttion))))
(defn disable-creat-button
[db _]
(assoc db :disable-group-creation true))
(defn dispatch-create-group
[_ [_ group-name]]
(dispatch [:create-new-group group-name]))
(register-handler :init-group-creation
(after dispatch-create-group)
disable-creat-button)
; todo rewrite ; todo rewrite
(register-handler :group-chat-invite-received (register-handler :group-chat-invite-received

View File

@ -18,12 +18,14 @@
(defview new-group-toolbar [] (defview new-group-toolbar []
[group-name [:get ::group-name]] [group-name [:get ::group-name]
creation-disabled? [:get :disable-group-creation]]
[toolbar [toolbar
{:title "New group chat" {:title "New group chat"
:action {:image {:source res/v ;; {:uri "icon_search"} :action {:image {:source res/v ;; {:uri "icon_search"}
:style st/toolbar-icon} :style st/toolbar-icon}
:handler #(dispatch [:create-new-group group-name])}}]) :handler (when-not creation-disabled?
#(dispatch [:init-group-creation group-name]))}}])
(defview group-name-input [] (defview group-name-input []
[group-name [:get ::group-name]] [group-name [:get ::group-name]]