diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index be0d127060..d53f935926 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -203,24 +203,6 @@ (dispatch [:set-chat-command command type]) (dispatch [:set-chat-command-content text])))) -(register-handler :set-staged-commands-scroll-view - (fn [{:keys [current-chat-id] :as db} [_ view]] - (assoc-in db [:chats current-chat-id :staged-scroll-view] view))) - -(register-handler :set-staged-commands-scroll-height - (fn [{:keys [current-chat-id] :as db} [_ height]] - (assoc-in db [:chats current-chat-id :staged-scroll-height] height))) - -(register-handler :staged-commands-scroll-to - (u/side-effect! - (fn [{:keys [current-chat-id chats]} [_ height]] - (let [{:keys [staged-scroll-view staged-scroll-height]} (get chats current-chat-id)] - (when staged-scroll-view - (let [y (if (< 0 staged-scroll-height height) - (- height staged-scroll-height) - 0)] - (.scrollTo staged-scroll-view (clj->js {:x 0 :y y})))))))) - (register-handler :set-message-input-view-height (fn [{:keys [current-chat-id] :as db} [_ height]] (assoc-in db [:chats current-chat-id :message-input-height] height))) diff --git a/src/status_im/chat/handlers/commands.cljs b/src/status_im/chat/handlers/commands.cljs index acd80a556e..4ab0721ff8 100644 --- a/src/status_im/chat/handlers/commands.cljs +++ b/src/status_im/chat/handlers/commands.cljs @@ -90,7 +90,8 @@ (status/call-jail chat-id path params - #(dispatch [:command-preview chat-id id %]))))) + #(do (dispatch [:command-preview chat-id id %]) + (dispatch [:send-chat-message])))))) (defn command-input ([{:keys [current-chat-id] :as db}] diff --git a/src/status_im/chat/handlers/send_message.cljs b/src/status_im/chat/handlers/send_message.cljs index 4f9943b0c5..32f0b47ed8 100644 --- a/src/status_im/chat/handlers/send_message.cljs +++ b/src/status_im/chat/handlers/send_message.cljs @@ -182,7 +182,7 @@ (register-handler ::prepare-message (u/side-effect! - (fn [{:keys [network-status]} [_ {:keys [chat-id identity message] :as params}]] + (fn [{:keys [network-status] :as db} [_ {:keys [chat-id identity message] :as params}]] (let [{:keys [group-chat]} (get-in db [:chats chat-id]) clock-value (messages/get-last-clock-value chat-id) message' (cu/check-author-direction diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 326eeabfde..97961baa86 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -23,7 +23,6 @@ [status-im.chat.views.datemark :refer [chat-datemark]] [status-im.chat.views.response :refer [response-view]] [status-im.chat.views.new-message :refer [chat-message-input-view]] - [status-im.chat.views.staged-commands :refer [staged-commands-view]] [status-im.chat.views.actions :refer [actions-view]] [status-im.chat.views.emoji :refer [emoji-view]] [status-im.chat.views.bottom-info :refer [bottom-info-view]] @@ -173,7 +172,6 @@ (defview messages-container [messages] [offset [:messages-offset] - staged-scroll-height [:get-chat-staged-commands-scroll-height] messages-offset (anim/create-value 0) context {:offset offset :val messages-offset} @@ -181,7 +179,7 @@ {:component-did-mount on-update :component-did-update on-update} [animated-view - {:style (st/messages-container staged-scroll-height messages-offset)} + {:style (st/messages-container messages-offset)} messages]) (defview chat [] @@ -190,7 +188,6 @@ show-bottom-info? [:chat-ui-props :show-bottom-info?] show-emoji? [:chat-ui-props :show-emoji?] command? [:command?] - staged-commands [:get-chat-staged-commands] layout-height [:get :layout-height]] {:component-did-mount #(dispatch [:check-autorun])} [view {:style st/chat-view @@ -203,8 +200,6 @@ [messages-view group-chat]] ;; todo uncomment this #_(when @group-chat [typing-all]) - (when (seq staged-commands) - [staged-commands-view staged-commands]) (when-not command? [suggestion-container]) [response-view] @@ -215,4 +210,5 @@ [actions-view]) (when show-bottom-info? [bottom-info-view]) - [offline-view {:top (get-in platform-specific [:component-styles :status-bar :default :height])}]]) + [offline-view {:top (get-in platform-specific + [:component-styles :status-bar :default :height])}]]) diff --git a/src/status_im/chat/styles/input.cljs b/src/status_im/chat/styles/input.cljs index 8e299786c2..f50a2c4e92 100644 --- a/src/status_im/chat/styles/input.cljs +++ b/src/status_im/chat/styles/input.cljs @@ -70,54 +70,3 @@ :width 12 :height 12}) -(defn staged-commands [message-input-height input-margin] - {:position :absolute - :background-color color-white - :bottom (+ message-input-height input-margin) - :left 0 - :right 0 - :max-height 150 - :elevation 5}) - -(def staged-command-container - {:flex 1 - :alignItems :flex-start - :flexDirection :column - :backgroundColor color-white}) - -(def staged-command-background - {:flexDirection :column - :margin-top 16 - :margin-left 16 - :margin-right 0 - :padding-bottom 12 - :padding-left 12 - :backgroundColor chat-background - :borderRadius 14}) - -(def staged-command-header - {:flex-direction :row - :justify-content :space-between}) - -(def staged-command-info-container - {:flexDirection :row - :margin-top 12}) - -(def staged-command-cancel - {:padding-left 12 - :padding-top 16 - :padding-right 12}) - -(def staged-command-cancel-icon - {:width 16 - :height 16}) - -(def staged-command-content - {:marginTop 5 - :marginHorizontal 0 - :fontSize 14 - :color color-black}) - -(def staged-commands-bottom - {:height 16 - :background-color "white"}) diff --git a/src/status_im/chat/styles/response.cljs b/src/status_im/chat/styles/response.cljs index 835d4906ff..453bc43589 100644 --- a/src/status_im/chat/styles/response.cljs +++ b/src/status_im/chat/styles/response.cljs @@ -49,10 +49,10 @@ :opacity 0.69 :color color-white}) -(defn response-view [height input-margin staged-commands] +(defn response-view [height input-margin] {:flexDirection :column :position :absolute - :elevation (if (seq staged-commands) 5 4) + :elevation 4 :left 0 :right 0 :bottom input-margin diff --git a/src/status_im/chat/styles/screen.cljs b/src/status_im/chat/styles/screen.cljs index a0757d6fd0..95d138bb26 100644 --- a/src/status_im/chat/styles/screen.cljs +++ b/src/status_im/chat/styles/screen.cljs @@ -16,10 +16,10 @@ (def toolbar-container {}) -(defn messages-container [staged-height bottom] +(defn messages-container [bottom] {:flex 1 :padding-bottom bottom - :margin-bottom staged-height}) + :margin-bottom 0}) (def toolbar-view {:flexDirection :row diff --git a/src/status_im/chat/styles/suggestions.cljs b/src/status_im/chat/styles/suggestions.cljs index 2a85de1d74..1f8c9d01df 100644 --- a/src/status_im/chat/styles/suggestions.cljs +++ b/src/status_im/chat/styles/suggestions.cljs @@ -67,7 +67,7 @@ :fontSize 12 :color text2-color}) -(defn container [height input-margin staged-commands] +(defn container [height input-margin] {:flexDirection :column :position :absolute :left 0 @@ -75,7 +75,7 @@ :bottom input-margin :height height :backgroundColor color-white - :elevation (if (seq staged-commands) 5 4)}) + :elevation 4}) (def request-container {:height 56 diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index 3371256d3a..43bba5b12a 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -89,13 +89,6 @@ (let [commands (subscribe [:get-chat-staged-commands])] (reaction (some #(= id (:to-message %)) @commands))))) -(register-sub :get-chat-staged-commands-scroll-height - (fn [db _] - (let [{:keys [staged-commands - staged-scroll-height]} (get-in @db [:chats (:current-chat-id @db)])] - (reaction - (if (seq staged-commands) staged-scroll-height 0))))) - (register-sub :get-message-input-view-height (fn [db _] (reaction (get-in @db [:chats (:current-chat-id @db) :message-input-height])))) diff --git a/src/status_im/chat/views/new_message.cljs b/src/status_im/chat/views/new_message.cljs index f526bb7cd6..2b17865be2 100644 --- a/src/status_im/chat/views/new_message.cljs +++ b/src/status_im/chat/views/new_message.cljs @@ -5,7 +5,6 @@ [status-im.components.react :refer [view scroll-view]] [status-im.chat.views.message-input :refer [plain-message-input-view]] - [status-im.chat.views.staged-commands :refer [simple-command-staged-view]] [status-im.chat.constants :refer [input-height]] [status-im.utils.platform :refer [platform-specific]] [status-im.chat.styles.message :as st] @@ -34,13 +33,11 @@ parameter [:get-command-parameter] type [:command-type] suggestions [:get-suggestions] - staged-commands [:get-chat-staged-commands] message-input-height [:get-message-input-view-height]] (let [on-top? (or (and (not (empty? suggestions)) (not command?)) (not= response-height input-height)) - style (when-not (seq staged-commands) - (get-in platform-specific [:component-styles :chat :new-message]))] + style (get-in platform-specific [:component-styles :chat :new-message])] [view {:style (merge (st/new-message-container margin on-top?) style) :on-layout (fn [event] (let [height (get-height event)] diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index 4afc85e5ce..e274a6952b 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -94,7 +94,6 @@ input-margin (subscribe [:input-margin]) changed (subscribe [:animations :response-height-changed]) animate? (subscribe [:animate?]) - staged-commands (subscribe [:get-chat-staged-commands]) context {:to-value to-response-height :val response-height :animate? animate?} @@ -109,8 +108,7 @@ @to-response-height @changed (into [animated-view {:style (st/response-view response-height - @input-margin - @staged-commands)}] + @input-margin)}] children))}))) (defn on-navigation-change diff --git a/src/status_im/chat/views/staged_commands.cljs b/src/status_im/chat/views/staged_commands.cljs deleted file mode 100644 index 4597e2dc90..0000000000 --- a/src/status_im/chat/views/staged_commands.cljs +++ /dev/null @@ -1,61 +0,0 @@ -(ns status-im.chat.views.staged-commands - (:require-macros [status-im.utils.views :refer [defview]]) - (:require [re-frame.core :refer [subscribe dispatch]] - [status-im.components.react :refer [view - image - icon - text - touchable-highlight - scroll-view]] - [status-im.chat.styles.input :as st] - [status-im.chat.styles.command-pill :as pill-st] - [status-im.utils.platform :refer [platform-specific]] - [taoensso.timbre :as log])) - -(defn cancel-command-input [staged-command] - (dispatch [:unstage-command staged-command])) - -(defn get-height [event] - (.-height (.-layout (.-nativeEvent event)))) - -(defn simple-command-staged-view - [{:keys [command params] :as staged-command}] - (let [{:keys [type name]} command] - [view st/staged-command-container - [view st/staged-command-background - [view st/staged-command-header - [view st/staged-command-info-container - [view (pill-st/pill command) - [text {:style pill-st/pill-text} - (str - (if (= :command type) "!" "?") - name)]]] - [touchable-highlight {:style st/staged-command-cancel - :onPress #(cancel-command-input staged-command)} - [view [icon :close_small_gray - st/staged-command-cancel-icon]]]] - [view {:padding-right 12} - (if-let [preview (:preview staged-command)] - preview - [text {:style st/staged-command-content} - (if (= 1 (count params)) - (first (vals params)) - (str params))])]]])) - -(defn staged-command-view [stage-command] - [simple-command-staged-view stage-command]) - -(defview staged-commands-view [staged-commands] - [message-input-height [:get-message-input-view-height] - input-margin [:input-margin]] - (let [style (when (seq staged-commands) - (get-in platform-specific [:component-styles :chat :new-message]))] - [view {:style (merge (st/staged-commands message-input-height input-margin) - style)} - [scroll-view {:bounces false - :ref #(dispatch [:set-staged-commands-scroll-view %]) - :on-layout #(dispatch [:set-staged-commands-scroll-height (get-height %)])} - [view {:on-layout #(dispatch [:staged-commands-scroll-to (get-height %)])} - (for [command staged-commands] - ^{:key command} [staged-command-view command]) - [view st/staged-commands-bottom]]]])) diff --git a/src/status_im/chat/views/suggestions.cljs b/src/status_im/chat/views/suggestions.cljs index 528c566b4b..32353a36c6 100644 --- a/src/status_im/chat/views/suggestions.cljs +++ b/src/status_im/chat/views/suggestions.cljs @@ -109,7 +109,6 @@ input-margin (subscribe [:input-margin]) changed (subscribe [:animations :commands-height-changed]) animate? (subscribe [:animate?]) - staged-commands (subscribe [:get-chat-staged-commands]) context {:to-value to-response-height :val h :animate? animate?} @@ -122,9 +121,9 @@ :reagent-render (fn [h & elements] @to-response-height @changed - (into [animated-view {:style (st/container h @input-margin @staged-commands)}] elements))}))) + (into [animated-view {:style (st/container h @input-margin)}] elements))}))) -(defview suggestion-container [any-staged-commands?] +(defview suggestion-container [] (let [h (anim/create-value c/input-height)] [container h [header h] diff --git a/src/status_im/data_store/discover.cljs b/src/status_im/data_store/discover.cljs index 20aca4cef8..23108fd516 100644 --- a/src/status_im/data_store/discover.cljs +++ b/src/status_im/data_store/discover.cljs @@ -1,5 +1,6 @@ (ns status-im.data-store.discover - (:require [status-im.data-store.realm.discover :as data-store])) + (:require [status-im.data-store.realm.discover :as data-store]) + (:refer-clojure :exclude [exists?])) (defn get-all [ordering] @@ -24,4 +25,4 @@ (defn get-all-tags [] - (data-store/get-all-tags)) \ No newline at end of file + (data-store/get-all-tags)) diff --git a/src/status_im/protocol/message_cache.cljs b/src/status_im/protocol/message_cache.cljs index 8a1fd5d55d..969ae7041b 100644 --- a/src/status_im/protocol/message_cache.cljs +++ b/src/status_im/protocol/message_cache.cljs @@ -1,4 +1,5 @@ -(ns status-im.protocol.message-cache) +(ns status-im.protocol.message-cache + (:refer-clojure :exclude [exists?])) (defonce messages-set (atom #{})) (defonce messages-map (atom {}))