Merge branch 'design' into icons_resolution
This commit is contained in:
commit
7ee1625b31
|
@ -13,6 +13,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
handle-command
|
handle-command
|
||||||
get-command-handler
|
get-command-handler
|
||||||
load-commands
|
load-commands
|
||||||
apply-staged-commands]]
|
apply-staged-commands
|
||||||
|
check-suggestion]]
|
||||||
[syng-im.handlers.sign-up :as sign-up-service]
|
[syng-im.handlers.sign-up :as sign-up-service]
|
||||||
|
|
||||||
[syng-im.models.chats :refer [create-chat
|
[syng-im.models.chats :refer [create-chat
|
||||||
|
@ -392,7 +393,10 @@
|
||||||
|
|
||||||
(register-handler :set-chat-input-text
|
(register-handler :set-chat-input-text
|
||||||
(fn [db [_ text]]
|
(fn [db [_ text]]
|
||||||
(set-chat-input-text db text)))
|
(let [{:keys [command]} (check-suggestion db text)]
|
||||||
|
(-> db
|
||||||
|
(set-chat-input-text text)
|
||||||
|
(set-chat-command command)))))
|
||||||
|
|
||||||
(register-handler :set-chat-command
|
(register-handler :set-chat-command
|
||||||
(fn [db [_ command-key]]
|
(fn [db [_ command-key]]
|
||||||
|
|
|
@ -154,21 +154,21 @@
|
||||||
|
|
||||||
(defn intro [db]
|
(defn intro [db]
|
||||||
(dispatch [:received-msg
|
(dispatch [:received-msg
|
||||||
{:msg-id (random/id)
|
{:msg-id "intro-message1"
|
||||||
:content "Hello there! It's Syng, a Dapp browser in your phone."
|
:content "Hello there! It's Syng, a Dapp browser in your phone."
|
||||||
:content-type text-content-type
|
:content-type text-content-type
|
||||||
:outgoing false
|
:outgoing false
|
||||||
:from "console"
|
:from "console"
|
||||||
:to "me"}])
|
:to "me"}])
|
||||||
(dispatch [:received-msg
|
(dispatch [:received-msg
|
||||||
{:msg-id (random/id)
|
{:msg-id "intro-message2"
|
||||||
:content (str "Syng uses a highly secure key-pair authentication type "
|
:content (str "Syng uses a highly secure key-pair authentication type "
|
||||||
"to provide you a reliable way to access your account")
|
"to provide you a reliable way to access your account")
|
||||||
:content-type text-content-type
|
:content-type text-content-type
|
||||||
:outgoing false
|
:outgoing false
|
||||||
:from "console"
|
:from "console"
|
||||||
:to "me"}])
|
:to "me"}])
|
||||||
(let [msg-id (random/id)]
|
(let [msg-id "into-message3"]
|
||||||
(dispatch [:received-msg
|
(dispatch [:received-msg
|
||||||
{:msg-id msg-id
|
{:msg-id msg-id
|
||||||
:content (commands/format-command-request-msg-content
|
:content (commands/format-command-request-msg-content
|
||||||
|
|
|
@ -9,23 +9,27 @@
|
||||||
get-chat-command-to-msg-id
|
get-chat-command-to-msg-id
|
||||||
clear-staged-commands]]
|
clear-staged-commands]]
|
||||||
[syng-im.utils.utils :refer [log on-error http-get]]
|
[syng-im.utils.utils :refer [log on-error http-get]]
|
||||||
[syng-im.utils.logging :as log]))
|
[syng-im.utils.logging :as log]
|
||||||
|
[clojure.string :as s]))
|
||||||
|
|
||||||
|
(defn suggestion? [text]
|
||||||
|
(= (get text 0) "!"))
|
||||||
|
|
||||||
(defn get-suggestions [db text]
|
(defn get-suggestions [db text]
|
||||||
(if (= (get text 0) "!")
|
(if (suggestion? text)
|
||||||
;; TODO change 'commands' to 'suggestions'
|
;; TODO change 'commands' to 'suggestions'
|
||||||
(filterv #(.startsWith (:text %) text) (get-commands db))
|
(filterv #(.startsWith (:text %) text) (get-commands db))
|
||||||
[]))
|
[]))
|
||||||
|
|
||||||
(defn get-command [db text]
|
(defn get-command [db text]
|
||||||
(when (= (get text 0) "!")
|
(when (suggestion? text)
|
||||||
;; TODO change 'commands' to 'suggestions'
|
;; TODO change 'commands' to 'suggestions'
|
||||||
(first (filter #(= (:text %) text) (get-commands db)))))
|
(first (filter #(= (:text %) text) (get-commands db)))))
|
||||||
|
|
||||||
(defn handle-command [db command-key content]
|
(defn handle-command [db command-key content]
|
||||||
(when-let [command-handler (get-chat-command-request db)]
|
(when-let [command-handler (get-chat-command-request db)]
|
||||||
(let [to-msg-id (get-chat-command-to-msg-id db)]
|
(let [to-msg-id (get-chat-command-to-msg-id db)]
|
||||||
(command-handler to-msg-id command-key content)))
|
(command-handler to-msg-id command-key content)))
|
||||||
db)
|
db)
|
||||||
|
|
||||||
(defn get-command-handler [db command-key content]
|
(defn get-command-handler [db command-key content]
|
||||||
|
@ -53,3 +57,11 @@
|
||||||
|
|
||||||
(defn load-commands []
|
(defn load-commands []
|
||||||
(http-get "chat-commands.js" execute-commands-js nil))
|
(http-get "chat-commands.js" execute-commands-js nil))
|
||||||
|
|
||||||
|
(defn check-suggestion [db message]
|
||||||
|
(when-let [suggestion-text (when (string? message)
|
||||||
|
(re-matches #"^![^\s]+\s" message))]
|
||||||
|
(let [suggestion-text' (s/trim suggestion-text)
|
||||||
|
[suggestion] (filter #(= suggestion-text' (:text %))
|
||||||
|
(get-commands db))]
|
||||||
|
suggestion)))
|
||||||
|
|
|
@ -38,7 +38,10 @@
|
||||||
|
|
||||||
(register-sub :get-suggestions
|
(register-sub :get-suggestions
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [input-text (reaction (get-in @db (db/chat-input-text-path (current-chat-id @db))))]
|
(let [input-text (->> (current-chat-id @db)
|
||||||
|
db/chat-input-text-path
|
||||||
|
(get-in @db)
|
||||||
|
(reaction))]
|
||||||
(reaction (get-suggestions @db @input-text)))))
|
(reaction (get-suggestions @db @input-text)))))
|
||||||
|
|
||||||
(register-sub :get-commands
|
(register-sub :get-commands
|
||||||
|
|
Loading…
Reference in New Issue