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

@ -7,27 +7,28 @@
(def default-view :chat-list)
;; initial state of app-db
(def app-db {:identity-password "replace-me-with-user-entered-password"
:identity "me"
:contacts []
:contacts-ids #{}
:selected-contacts #{}
:current-chat-id "console"
:chat {:command nil
:last-message nil}
:chats {}
:chats-updated-signal 0
:show-actions false
:new-participants #{}
:signed-up true
:view-id default-view
:navigation-stack (list default-view)
(def app-db {:identity-password "replace-me-with-user-entered-password"
:identity "me"
:contacts []
:contacts-ids #{}
:selected-contacts #{}
:current-chat-id "console"
:chat {:command nil
:last-message nil}
:chats {}
:chats-updated-signal 0
:show-actions false
:new-participants #{}
:signed-up true
:view-id default-view
:navigation-stack (list default-view)
;; TODO fix hardcoded values
:username "My Name"
:phone-number "3147984309"
:email "myemail@gmail.com"
:status "Hi, this is my status"
:current-tag nil})
:username "My Name"
:phone-number "3147984309"
:email "myemail@gmail.com"
:status "Hi, this is my status"
:current-tag nil
:disable-group-creation false})
(def protocol-initialized-path [:protocol-initialized])
(defn chat-input-text-path [chat-id]

View File

@ -58,12 +58,29 @@
[{:keys [new-group-id]} _]
(dispatch [:show-chat new-group-id :replace]))
(defn enable-creat-buttion
[db _]
(assoc db :disable-group-creation false))
(register-handler :create-new-group
(-> start-group-chat!
((enrich prepare-chat))
((enrich add-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
(register-handler :group-chat-invite-received

View File

@ -18,12 +18,14 @@
(defview new-group-toolbar []
[group-name [:get ::group-name]]
[group-name [:get ::group-name]
creation-disabled? [:get :disable-group-creation]]
[toolbar
{:title "New group chat"
:action {:image {:source res/v ;; {:uri "icon_search"}
: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 []
[group-name [:get ::group-name]]