chat: change command char from ! to / #687

This commit is contained in:
Gustavo Nunes 2017-01-10 01:59:25 -02:00
parent db3c3111d0
commit c948b9b88e
7 changed files with 19 additions and 12 deletions

View File

@ -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)

View File

@ -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

View File

@ -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]

View File

@ -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))]]])

View File

@ -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]])

View File

@ -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 [_]

View File

@ -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}]]))