Former-commit-id: 64c8e666ff
This commit is contained in:
Roman Volosovskyi 2016-10-27 14:54:24 +03:00
parent b9d29b7fd8
commit 84ba111f08
2 changed files with 79 additions and 68 deletions

View File

@ -344,14 +344,16 @@
((after save-new-chat!))))
(defn update-chat!
[_ [_ chat]]
(chats/save chat))
[_ [_ {:keys [name] :as chat}]]
(let [chat' (if name chat (dissoc chat :name))]
(chats/save chat')))
(register-handler :update-chat!
(-> (fn [db [_ {:keys [chat-id] :as chat}]]
(-> (fn [db [_ {:keys [chat-id name] :as chat}]]
(let [chat' (if name chat (dissoc chat :name))]
(if (get-in db [:chats chat-id])
(update-in db [:chats chat-id] merge chat)
db))
(update-in db [:chats chat-id] merge chat')
db)))
((after update-chat!))))
(register-handler :upsert-chat!

View File

@ -17,7 +17,9 @@
[status-im.resources :as res]
[status-im.utils.gfycat.core :refer [generate-gfy]]
[status-im.i18n :refer [label]]
[status-im.components.react :refer [dismiss-keyboard!]]))
[status-im.components.react :refer [dismiss-keyboard!]]
[clojure.string :as str]
[cljs.spec :as s]))
(defonce drawer-atom (atom))
@ -42,10 +44,15 @@
:font :default}
name]])
(defview drawer-menu []
[{:keys [name photo-path status]} [:get-current-account]
{new-name :name new-status :status} [:get :profile-edit]
keyboard-height [:get :keyboard-height]]
(defn drawer-menu []
(let
[account (subscribe [:get-current-account])
profile (subscribe [:get :profile-edit])
keyboard-height (subscribe [:get :keyboard-height])
placeholder (generate-gfy)]
(fn []
(let [{:keys [name photo-path status]} @account
{new-name :name new-status :status} @profile]
[view st/drawer-menu
[touchable-without-feedback {:on-press #(dismiss-keyboard!)}
[view st/drawer-menu
@ -56,13 +63,14 @@
[text-field
{:line-color :white
:focus-line-color :white
:placeholder (generate-gfy)
:placeholder placeholder
:editable true
:input-style (st/name-input-text (s/valid? ::v/name (or new-name name)))
:wrapper-style st/name-input-wrapper
:value name
:on-change-text #(dispatch [:set-in [:profile-edit :name] %])
:on-end-editing #(dispatch [:account-update {:name new-name}])}]]
:on-end-editing #(when (and new-name (not (str/blank? new-name)))
(dispatch [:account-update {:name new-name}]))}]]
[view st/status-container
[text-input {:style st/status-input
:editable true
@ -72,9 +80,10 @@
:accessibility-label :input
:placeholder (label :t/profile-no-status)
:on-change-text #(dispatch [:set-in [:profile-edit :status] %])
:on-blur (fn[]
:on-blur (fn []
(when (and new-status (not (str/blank? new-status)))
(dispatch [:check-status-change new-status])
(dispatch [:account-update {:status new-status}]))
(dispatch [:account-update {:status new-status}])))
:default-value status}]]
[view st/menu-items-container
[menu-item {:name (label :t/profile)
@ -93,7 +102,7 @@
)}]
[menu-item {:name (label :t/faq)
:handler (fn [])}]]
(when (= keyboard-height 0)
(when (= @keyboard-height 0)
[view st/switch-users-container
[touchable-opacity {:onPress (fn []
(close-drawer)
@ -102,7 +111,7 @@
)}
[text {:style st/switch-users-text
:font :default}
(label :t/switch-users)]]])]]])
(label :t/switch-users)]]])]]]))))
(defn drawer-view [items]
[drawer-layout {:drawerWidth 260