diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index abcf1e4393..4af77d29ba 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -20,8 +20,7 @@ [status-im.utils.phone-number :refer [format-phone-number]] [status-im.utils.datetime :as time] [status-im.chat.handlers.animation :refer [update-response-height - get-response-height - init-response-dragging]])) + get-response-height]])) (def delta 1) @@ -273,9 +272,7 @@ (defn init-chat ([db] (init-chat db nil)) ([{:keys [messages current-chat-id] :as db} _] - (-> db - (assoc-in [:chats current-chat-id :messages] messages) - (init-response-dragging)))) + (assoc-in db [:chats current-chat-id :messages] messages))) (register-handler :init-chat (-> load-messages! diff --git a/src/status_im/chat/handlers/animation.cljs b/src/status_im/chat/handlers/animation.cljs index 900bfb9a19..5f0c918da0 100644 --- a/src/status_im/chat/handlers/animation.cljs +++ b/src/status_im/chat/handlers/animation.cljs @@ -1,6 +1,5 @@ (ns status-im.chat.handlers.animation (:require [re-frame.core :refer [register-handler after dispatch]] - [status-im.components.drag-drop :as drag] [status-im.models.commands :as commands] [status-im.handlers.content-suggestions :refer [get-content-suggestions]] [status-im.chat.styles.plain-input :refer [input-height]] @@ -91,13 +90,3 @@ :else max-height)] (dispatch [:animate-response-resize]) (assoc-in db [:animations :to-response-height] new-fixed)))) - -(defn create-response-pan-responder [] - (drag/create-pan-responder - {:on-move (fn [e gesture] - (dispatch [:on-drag-response (.-dy gesture)])) - :on-release (fn [e gesture] - (dispatch [:fix-response-height]))})) - -(defn init-response-dragging [db] - (assoc-in db [:animations :response-pan-responder] (create-response-pan-responder))) diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index 37bc12385a..e1f1a0f74c 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -58,11 +58,17 @@ (dispatch [:cancel-command])))))) (anim/set-value val @current-value)))) +(defn create-response-pan-responder [] + (drag/create-pan-responder + {:on-move (fn [e gesture] + (dispatch [:on-drag-response (.-dy gesture)])) + :on-release (fn [e gesture] + (dispatch [:fix-response-height]))})) + (defn inner-container [content] - (let [pan-responder (subscribe [:get-in [:animations :response-pan-responder]]) + (let [pan-responder (create-response-pan-responder) commands-input-is-switching? (subscribe [:get-in [:animations :commands-input-is-switching?]]) response-resize? (subscribe [:get-in [:animations :response-resize?]]) - to-response-height (subscribe [:get-in [:animations :to-response-height]]) cur-response-height (subscribe [:get-in [:animations :response-height-current]]) response-height (anim/create-value (or @cur-response-height 0)) @@ -79,7 +85,7 @@ :reagent-render (fn [content] @to-response-height - [animated-view (merge (drag/pan-handlers @pan-responder) + [animated-view (merge (drag/pan-handlers pan-responder) {:style (st/response-view (if (or @commands-input-is-switching? @response-resize?) response-height (or @cur-response-height 0)))}) diff --git a/src/status_im/db.cljs b/src/status_im/db.cljs index 5fa2ad7f22..c79babb995 100644 --- a/src/status_im/db.cljs +++ b/src/status_im/db.cljs @@ -35,11 +35,10 @@ :animations {;; mutable data :to-response-height nil :response-height-current nil - :response-pan-responder nil :message-input-offset 0 :message-input-buttons-scale 1 - :commands-input-is-switching? false :messages-offset 0 + :commands-input-is-switching? false :response-resize? false}}) (def protocol-initialized-path [:protocol-initialized])