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