[#5934] persist text in message input field after navigating to user profile and back
This commit is contained in:
parent
f558e94e99
commit
d35b15e54e
|
@ -180,8 +180,12 @@
|
|||
:current-public-key current-public-key)]))]]
|
||||
[connectivity/error-view]])))
|
||||
|
||||
(views/defview chat-text-input []
|
||||
(views/defview chat-text-input [chat-id input-text]
|
||||
(views/letsubs [inp-ref (atom nil)]
|
||||
{:should-component-update
|
||||
(fn [_ [_ old-chat-id] [_ new-chat-id]]
|
||||
;; update component only when switch to another chat
|
||||
(not= old-chat-id new-chat-id))}
|
||||
(let [component (reagent/current-component)
|
||||
set-container-height-fn #(reagent/set-state component {:container-height %})
|
||||
{:keys [container-height empty?] :or {empty? true}} (reagent/state component)]
|
||||
|
@ -193,6 +197,7 @@
|
|||
:style (styles/chat-text-input container-height)
|
||||
:font :default
|
||||
:ref #(reset! inp-ref %)
|
||||
:default-value input-text
|
||||
:on-content-size-change #(set-container-height-fn (.-height (.-contentSize (.-nativeEvent %))))
|
||||
:on-key-press (fn [e]
|
||||
(let [native-event (.-nativeEvent e)
|
||||
|
@ -217,11 +222,11 @@
|
|||
[icons/icon :icons/arrow-left {:style (styles/send-icon-arrow empty?)}]]]])))
|
||||
|
||||
(views/defview chat-view []
|
||||
(views/letsubs [current-chat [:get-current-chat]]
|
||||
(views/letsubs [{:keys [input-text chat-id] :as current-chat} [:get-current-chat]]
|
||||
[react/view {:style styles/chat-view}
|
||||
[toolbar-chat-view current-chat]
|
||||
[messages-view current-chat]
|
||||
[chat-text-input]]))
|
||||
[chat-text-input chat-id input-text]]))
|
||||
|
||||
(views/defview chat-profile []
|
||||
(letsubs [identity [:get-current-contact-identity]
|
||||
|
|
Loading…
Reference in New Issue