parent
4a5623285a
commit
7ecce32a86
|
@ -27,7 +27,8 @@
|
|||
[view st/input-container
|
||||
[suggestions-view]
|
||||
[view st/input-view
|
||||
[icon :list st/list-icon]
|
||||
[touchable-highlight {:on-press #(dispatch [:switch-command-suggestions])}
|
||||
[view nil [icon :list st/list-icon]]]
|
||||
[text-input {:style st/message-input
|
||||
:autoFocus (pos? (count @staged-commands-atom))
|
||||
:onChangeText set-input-message
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
get-command-handler
|
||||
load-commands
|
||||
apply-staged-commands
|
||||
check-suggestion]]
|
||||
check-suggestion
|
||||
switch-command-suggestions]]
|
||||
[syng-im.handlers.sign-up :as sign-up-service]
|
||||
[syng-im.models.chats :refer [chat-exists?
|
||||
create-chat
|
||||
|
@ -487,6 +488,10 @@
|
|||
(register-handler :set-chat-input-text
|
||||
((enrich update-command) update-text))
|
||||
|
||||
(register-handler :switch-command-suggestions
|
||||
(fn [db [_]]
|
||||
(switch-command-suggestions db)))
|
||||
|
||||
(register-handler :set-chat-command
|
||||
(fn [db [_ command-key]]
|
||||
;; todo what is going on there?!
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
(ns syng-im.handlers.suggestions
|
||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[syng-im.db :as db]
|
||||
[syng-im.models.chat :refer [current-chat-id]]
|
||||
[syng-im.models.chat :refer [current-chat-id
|
||||
set-chat-input-text
|
||||
get-chat-input-text]]
|
||||
[syng-im.models.commands :refer [commands
|
||||
suggestions
|
||||
get-commands
|
||||
|
@ -62,3 +64,7 @@
|
|||
[suggestion] (filter #(= suggestion-text' (:text %))
|
||||
(get-commands db))]
|
||||
suggestion)))
|
||||
|
||||
(defn switch-command-suggestions [db]
|
||||
(let [text (get-chat-input-text db)]
|
||||
(set-chat-input-text db (if (suggestion? text) nil "!"))))
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
(defn set-chat-input-text [db text]
|
||||
(assoc-in db (db/chat-input-text-path (current-chat-id db)) text))
|
||||
|
||||
(defn get-chat-input-text [db]
|
||||
(get-in db (db/chat-input-text-path (current-chat-id db))))
|
||||
|
||||
(comment
|
||||
|
||||
(swap! re-frame.db/app-db (fn [db]
|
||||
|
|
Loading…
Reference in New Issue