parent
b9d29b7fd8
commit
84ba111f08
|
@ -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}]]
|
||||||
|
(let [chat' (if name chat (dissoc chat :name))]
|
||||||
(if (get-in db [:chats chat-id])
|
(if (get-in db [:chats chat-id])
|
||||||
(update-in db [:chats chat-id] merge chat)
|
(update-in db [:chats chat-id] merge chat')
|
||||||
db))
|
db)))
|
||||||
((after update-chat!))))
|
((after update-chat!))))
|
||||||
|
|
||||||
(register-handler :upsert-chat!
|
(register-handler :upsert-chat!
|
||||||
|
|
|
@ -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,10 +44,15 @@
|
||||||
: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])
|
||||||
|
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
|
[view st/drawer-menu
|
||||||
[touchable-without-feedback {:on-press #(dismiss-keyboard!)}
|
[touchable-without-feedback {:on-press #(dismiss-keyboard!)}
|
||||||
[view st/drawer-menu
|
[view st/drawer-menu
|
||||||
|
@ -56,13 +63,14 @@
|
||||||
[text-field
|
[text-field
|
||||||
{:line-color :white
|
{:line-color :white
|
||||||
:focus-line-color :white
|
:focus-line-color :white
|
||||||
:placeholder (generate-gfy)
|
:placeholder placeholder
|
||||||
:editable true
|
:editable true
|
||||||
:input-style (st/name-input-text (s/valid? ::v/name (or new-name name)))
|
:input-style (st/name-input-text (s/valid? ::v/name (or new-name name)))
|
||||||
:wrapper-style st/name-input-wrapper
|
:wrapper-style st/name-input-wrapper
|
||||||
:value name
|
:value name
|
||||||
:on-change-text #(dispatch [:set-in [:profile-edit :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
|
[view st/status-container
|
||||||
[text-input {:style st/status-input
|
[text-input {:style st/status-input
|
||||||
:editable true
|
:editable true
|
||||||
|
@ -72,9 +80,10 @@
|
||||||
:accessibility-label :input
|
:accessibility-label :input
|
||||||
:placeholder (label :t/profile-no-status)
|
:placeholder (label :t/profile-no-status)
|
||||||
:on-change-text #(dispatch [:set-in [:profile-edit :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 [:check-status-change new-status])
|
||||||
(dispatch [:account-update {:status new-status}]))
|
(dispatch [:account-update {:status new-status}])))
|
||||||
:default-value status}]]
|
:default-value status}]]
|
||||||
[view st/menu-items-container
|
[view st/menu-items-container
|
||||||
[menu-item {:name (label :t/profile)
|
[menu-item {:name (label :t/profile)
|
||||||
|
@ -93,7 +102,7 @@
|
||||||
)}]
|
)}]
|
||||||
[menu-item {:name (label :t/faq)
|
[menu-item {:name (label :t/faq)
|
||||||
:handler (fn [])}]]
|
:handler (fn [])}]]
|
||||||
(when (= keyboard-height 0)
|
(when (= @keyboard-height 0)
|
||||||
[view st/switch-users-container
|
[view st/switch-users-container
|
||||||
[touchable-opacity {:onPress (fn []
|
[touchable-opacity {:onPress (fn []
|
||||||
(close-drawer)
|
(close-drawer)
|
||||||
|
@ -102,7 +111,7 @@
|
||||||
)}
|
)}
|
||||||
[text {:style st/switch-users-text
|
[text {:style st/switch-users-text
|
||||||
:font :default}
|
:font :default}
|
||||||
(label :t/switch-users)]]])]]])
|
(label :t/switch-users)]]])]]]))))
|
||||||
|
|
||||||
(defn drawer-view [items]
|
(defn drawer-view [items]
|
||||||
[drawer-layout {:drawerWidth 260
|
[drawer-layout {:drawerWidth 260
|
||||||
|
|
Loading…
Reference in New Issue