From 02fb65516be5e408653403f673328fd832ac7174 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Thu, 19 May 2016 19:29:17 +0300 Subject: [PATCH] disable 'create button' until new chat will be opened Former-commit-id: 6e52fca420a9ac5ef129914742578c639fa85e58 --- src/syng_im/db.cljs | 41 +++++++++++++++-------------- src/syng_im/new_group/handlers.cljs | 19 ++++++++++++- src/syng_im/new_group/screen.cljs | 6 +++-- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/syng_im/db.cljs b/src/syng_im/db.cljs index 92c9c0d645..fa814e08a2 100644 --- a/src/syng_im/db.cljs +++ b/src/syng_im/db.cljs @@ -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] diff --git a/src/syng_im/new_group/handlers.cljs b/src/syng_im/new_group/handlers.cljs index bbd07a1f60..3823eb1c2e 100644 --- a/src/syng_im/new_group/handlers.cljs +++ b/src/syng_im/new_group/handlers.cljs @@ -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 diff --git a/src/syng_im/new_group/screen.cljs b/src/syng_im/new_group/screen.cljs index 85a344022b..c551dcca06 100644 --- a/src/syng_im/new_group/screen.cljs +++ b/src/syng_im/new_group/screen.cljs @@ -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]]