diff --git a/src/status_im/chat/constants.cljs b/src/status_im/chat/constants.cljs index e34f89c8b0..73b1327401 100644 --- a/src/status_im/chat/constants.cljs +++ b/src/status_im/chat/constants.cljs @@ -1,5 +1,7 @@ (ns status-im.chat.constants) +(def command-char "/") + (def input-height 56) (def max-input-height 66) (def min-input-height 22) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index d2f9360062..a4df2c3b46 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -5,6 +5,7 @@ [clojure.string :as string] [status-im.components.styles :refer [default-chat-color]] [status-im.chat.suggestions :as suggestions] + [status-im.chat.constants :as chat-consts] [status-im.protocol.core :as protocol] [status-im.data-store.chats :as chats] [status-im.data-store.contacts :as contacts] @@ -170,7 +171,7 @@ (fn [{:keys [current-chat-id]} [_ text]] ;; fixes https://github.com/status-im/status-react/issues/594 ;; todo: revisit with more clever solution - (let [text' (if (= text "! ") "!" text)] + (let [text' (if (= text (str chat-consts/command-char " ")) chat-consts/command-char text)] (if (console? current-chat-id) (dispatch [::check-input-for-commands text']) (dispatch [::check-suggestions current-chat-id text'])))))) @@ -468,7 +469,7 @@ (register-handler :switch-command-suggestions! (u/side-effect! (fn [db] - (let [text (if (suggestions/typing-command? db) "" "!")] + (let [text (if (suggestions/typing-command? db) "" chat-consts/command-char)] (dispatch [:set-chat-input-text text]))))) (defn remove-chat diff --git a/src/status_im/chat/suggestions.cljs b/src/status_im/chat/suggestions.cljs index 1de4d86970..b673da0354 100644 --- a/src/status_im/chat/suggestions.cljs +++ b/src/status_im/chat/suggestions.cljs @@ -1,6 +1,7 @@ (ns status-im.chat.suggestions (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [status-im.db :as db] + [status-im.chat.constants :as chat-consts] [status-im.models.commands :refer [get-commands get-chat-command-request get-chat-command-to-message-id]] @@ -8,11 +9,11 @@ [clojure.string :as s])) (defn suggestion? [text] - (= (get text 0) "!")) + (= (get text 0) chat-consts/command-char)) (defn can-be-suggested? [text] (fn [{:keys [name]}] - (.startsWith (str "!" name) text))) + (.startsWith (str chat-consts/command-char name) text))) (defn get-suggestions [{:keys [current-chat-id] :as db} text] @@ -43,7 +44,7 @@ (re-matches #"^![^\s]+\s" message))] (let [suggestion-text' (s/trim suggestion-text)] (->> (get-commands db) - (filter #(= suggestion-text' (->> % second :name (str "!")))) + (filter #(= suggestion-text' (->> % second :name (str chat-consts/command-char)))) first)))) (defn typing-command? [db] diff --git a/src/status_im/chat/views/command.cljs b/src/status_im/chat/views/command.cljs index 5b26a80aef..078f05c123 100644 --- a/src/status_im/chat/views/command.cljs +++ b/src/status_im/chat/views/command.cljs @@ -5,6 +5,7 @@ icon text touchable-highlight]] + [status-im.chat.constants :as chat-consts] [status-im.chat.styles.input :as st])) (defn set-input-message [message] @@ -23,4 +24,4 @@ (let [width (.. event -nativeEvent -layout -width)] (when (not= icon-width width) (dispatch [:set :command-icon-width width]))))} - [text {:style st/command-text} (str "!" (:name command))]]]) + [text {:style st/command-text} (str chat-consts/command-char (:name command))]]]) diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index c23decb890..b073cffebc 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -12,6 +12,7 @@ touchable-highlight get-dimensions]] [status-im.components.animation :as anim] + [status-im.chat.constants :as chat-consts] [status-im.chat.views.request-message :refer [message-content-command-request]] [status-im.chat.styles.message :as st] [status-im.chat.styles.command-pill :as pill-st] @@ -127,7 +128,7 @@ [view (pill-st/pill command) [text {:style pill-st/pill-text :font :default} - (str (if (= :command type) "!" "?") name)]]] + (str (if (= :command type) chat-consts/command-char "?") name)]]] (when icon-path [view st/command-image-view [icon icon-path st/command-image]]) diff --git a/src/status_im/chat/views/plain_message.cljs b/src/status_im/chat/views/plain_message.cljs index df4d6f5cef..d744fce3eb 100644 --- a/src/status_im/chat/views/plain_message.cljs +++ b/src/status_im/chat/views/plain_message.cljs @@ -10,6 +10,7 @@ dismiss-keyboard!]] [status-im.components.animation :as anim] [status-im.chat.styles.plain-message :as st] + [status-im.chat.constants :as chat-consts] [status-im.constants :refer [response-input-hiding-duration]])) (defn set-input-message [message] @@ -20,7 +21,7 @@ (defn message-valid? [ message] (and (pos? (count message)) - (not= "!" message))) + (not= chat-consts/command-char message))) (defn button-animation-logic [{:keys [command? val]}] (fn [_] diff --git a/src/status_im/chat/views/suggestions.cljs b/src/status_im/chat/views/suggestions.cljs index 32353a36c6..b055b8a985 100644 --- a/src/status_im/chat/views/suggestions.cljs +++ b/src/status_im/chat/views/suggestions.cljs @@ -19,7 +19,7 @@ [status-im.components.drag-drop :as drag] [status-im.utils.platform :refer [ios?]] [status-im.chat.suggestions-responder :as resp] - [status-im.chat.constants :as c] + [status-im.chat.constants :as chat-consts] [status-im.i18n :refer [label]] [status-im.chat.views.response :as response])) @@ -49,7 +49,7 @@ [[command {:keys [title description] name :name :as suggestion}]] - (let [label (str "!" name)] + (let [label (str chat-consts/command-char name)] [touchable-highlight {:onPress #(set-command-input command) :style st/suggestion-highlight} @@ -124,8 +124,8 @@ (into [animated-view {:style (st/container h @input-margin)}] elements))}))) (defview suggestion-container [] - (let [h (anim/create-value c/input-height)] + (let [h (anim/create-value chat-consts/input-height)] [container h [header h] [suggestions-view] - [view {:height c/input-height}]])) + [view {:height chat-consts/input-height}]]))