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!)))) ((after save-new-chat!))))
(defn update-chat! (defn update-chat!
[_ [_ chat]] [_ [_ {:keys [name] :as chat}]]
(chats/save chat)) (let [chat' (if name chat (dissoc chat :name))]
(chats/save chat')))
(register-handler :update-chat! (register-handler :update-chat!
(-> (fn [db [_ {:keys [chat-id] :as chat}]] (-> (fn [db [_ {:keys [chat-id name] :as chat}]]
(if (get-in db [:chats chat-id]) (let [chat' (if name chat (dissoc chat :name))]
(update-in db [:chats chat-id] merge chat) (if (get-in db [:chats chat-id])
db)) (update-in db [:chats chat-id] merge chat')
db)))
((after update-chat!)))) ((after update-chat!))))
(register-handler :upsert-chat! (register-handler :upsert-chat!

View File

@ -17,7 +17,9 @@
[status-im.resources :as res] [status-im.resources :as res]
[status-im.utils.gfycat.core :refer [generate-gfy]] [status-im.utils.gfycat.core :refer [generate-gfy]]
[status-im.i18n :refer [label]] [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)) (defonce drawer-atom (atom))
@ -42,67 +44,74 @@
:font :default} :font :default}
name]]) name]])
(defview drawer-menu [] (defn drawer-menu []
[{:keys [name photo-path status]} [:get-current-account] (let
{new-name :name new-status :status} [:get :profile-edit] [account (subscribe [:get-current-account])
keyboard-height [:get :keyboard-height]] profile (subscribe [:get :profile-edit])
[view st/drawer-menu keyboard-height (subscribe [:get :keyboard-height])
[touchable-without-feedback {:on-press #(dismiss-keyboard!)} placeholder (generate-gfy)]
[view st/drawer-menu (fn []
[touchable-opacity {:on-press #(dispatch [:navigate-to :my-profile])} (let [{:keys [name photo-path status]} @account
[view st/user-photo-container {new-name :name new-status :status} @profile]
[user-photo {:photo-path photo-path}]]] [view st/drawer-menu
[view st/name-container [touchable-without-feedback {:on-press #(dismiss-keyboard!)}
[text-field [view st/drawer-menu
{:line-color :white [touchable-opacity {:on-press #(dispatch [:navigate-to :my-profile])}
:focus-line-color :white [view st/user-photo-container
:placeholder (generate-gfy) [user-photo {:photo-path photo-path}]]]
:editable true [view st/name-container
:input-style (st/name-input-text (s/valid? ::v/name (or new-name name))) [text-field
:wrapper-style st/name-input-wrapper {:line-color :white
:value name :focus-line-color :white
:on-change-text #(dispatch [:set-in [:profile-edit :name] %]) :placeholder placeholder
:on-end-editing #(dispatch [:account-update {:name new-name}])}]] :editable true
[view st/status-container :input-style (st/name-input-text (s/valid? ::v/name (or new-name name)))
[text-input {:style st/status-input :wrapper-style st/name-input-wrapper
:editable true :value name
:multiline true :on-change-text #(dispatch [:set-in [:profile-edit :name] %])
:blur-on-submit true :on-end-editing #(when (and new-name (not (str/blank? new-name)))
:maxLength 140 (dispatch [:account-update {:name new-name}]))}]]
:accessibility-label :input [view st/status-container
:placeholder (label :t/profile-no-status) [text-input {:style st/status-input
:on-change-text #(dispatch [:set-in [:profile-edit :status] %]) :editable true
:on-blur (fn[] :multiline true
(dispatch [:check-status-change new-status]) :blur-on-submit true
(dispatch [:account-update {:status new-status}])) :maxLength 140
:default-value status}]] :accessibility-label :input
[view st/menu-items-container :placeholder (label :t/profile-no-status)
[menu-item {:name (label :t/profile) :on-change-text #(dispatch [:set-in [:profile-edit :status] %])
:handler #(dispatch [:navigate-to :my-profile])}] :on-blur (fn []
[menu-item {:name (label :t/settings) (when (and new-status (not (str/blank? new-status)))
:handler (fn [] (dispatch [:check-status-change new-status])
;; TODO not implemented (dispatch [:account-update {:status new-status}])))
)}] :default-value status}]]
[menu-item {:name (label :t/discovery) [view st/menu-items-container
:handler #(dispatch [:navigate-to :discovery])}] [menu-item {:name (label :t/profile)
[menu-item {:name (label :t/contacts) :handler #(dispatch [:navigate-to :my-profile])}]
:handler #(dispatch [:navigate-to :contact-list])}] [menu-item {:name (label :t/settings)
[menu-item {:name (label :t/invite-friends) :handler (fn []
:handler (fn [] ;; TODO not implemented
;; TODO not implemented )}]
)}] [menu-item {:name (label :t/discovery)
[menu-item {:name (label :t/faq) :handler #(dispatch [:navigate-to :discovery])}]
:handler (fn [])}]] [menu-item {:name (label :t/contacts)
(when (= keyboard-height 0) :handler #(dispatch [:navigate-to :contact-list])}]
[view st/switch-users-container [menu-item {:name (label :t/invite-friends)
[touchable-opacity {:onPress (fn [] :handler (fn []
(close-drawer) ;; TODO not implemented
(dispatch [:navigate-to :accounts]) )}]
;; TODO not implemented [menu-item {:name (label :t/faq)
)} :handler (fn [])}]]
[text {:style st/switch-users-text (when (= @keyboard-height 0)
:font :default} [view st/switch-users-container
(label :t/switch-users)]]])]]]) [touchable-opacity {:onPress (fn []
(close-drawer)
(dispatch [:navigate-to :accounts])
;; TODO not implemented
)}
[text {:style st/switch-users-text
:font :default}
(label :t/switch-users)]]])]]]))))
(defn drawer-view [items] (defn drawer-view [items]
[drawer-layout {:drawerWidth 260 [drawer-layout {:drawerWidth 260