This commit is contained in:
Roman Volosovskyi 2017-04-20 10:59:56 +03:00 committed by Roman Volosovskyi
parent 9d6f155c38
commit 4f7f5c11c9
1 changed files with 10 additions and 11 deletions

View File

@ -85,28 +85,27 @@
(register-sub (register-sub
:current-chat-argument-position :current-chat-argument-position
(fn [db [_ chat-id]] (fn [db]
(let [chat-id (or chat-id (@db :current-chat-id)) (let [command (subscribe [:selected-chat-command])
command (subscribe [:selected-chat-command chat-id]) input-text (subscribe [:chat :input-text])
input-text (subscribe [:chat :input-text chat-id]) seq-arguments (subscribe [:chat :seq-arguments])]
seq-arguments (subscribe [:chat :seq-arguments chat-id])]
(reaction (reaction
(input-model/current-chat-argument-position @command @input-text @seq-arguments))))) (input-model/current-chat-argument-position @command @input-text @seq-arguments)))))
(register-sub (register-sub
:chat-parameter-box :chat-parameter-box
(fn [db [_ chat-id]] (fn [db]
(let [chat-id (or chat-id (@db :current-chat-id)) (let [chat-id (subscribe [:get-current-chat-id])
command (subscribe [:selected-chat-command chat-id]) command (subscribe [:selected-chat-command])
index (subscribe [:current-chat-argument-position chat-id])] index (subscribe [:current-chat-argument-position])]
(reaction (reaction
(cond (cond
(and @command (> @index -1)) (and @command (> @index -1))
(let [command-name (get-in @command [:command :name])] (let [command-name (get-in @command [:command :name])]
(get-in @db [:chats chat-id :parameter-boxes command-name @index])) (get-in @db [:chats @chat-id :parameter-boxes command-name @index]))
(not @command) (not @command)
(get-in @db [:chats chat-id :parameter-boxes :message]) (get-in @db [:chats @chat-id :parameter-boxes :message])
:default :default
nil))))) nil)))))