fix #524
This commit is contained in:
parent
4854021005
commit
a99af99b7b
|
@ -81,6 +81,19 @@
|
|||
vals
|
||||
(reaction))))
|
||||
|
||||
(register-sub :get-chat-staged-commands-ids
|
||||
(fn [db _]
|
||||
(->> [:chats (:current-chat-id @db) :staged-commands]
|
||||
(get-in @db)
|
||||
vals
|
||||
(keep :to-message)
|
||||
(reaction))))
|
||||
|
||||
(register-sub :staged-response?
|
||||
(fn [_ [_ id]]
|
||||
(let [commands (subscribe [:get-chat-staged-commands])]
|
||||
(reaction (some #(= id (:to-message %)) @commands)))))
|
||||
|
||||
(register-sub :get-chat-staged-commands-scroll-height
|
||||
(fn [db _]
|
||||
(let [{:keys [staged-commands
|
||||
|
@ -177,8 +190,12 @@
|
|||
|
||||
(register-sub :get-requests
|
||||
(fn [db]
|
||||
(let [chat-id (subscribe [:get-current-chat-id])]
|
||||
(reaction (get-in @db [:chats @chat-id :requests])))))
|
||||
(let [chat-id (subscribe [:get-current-chat-id])
|
||||
staged-ids (subscribe [:get-chat-staged-commands-ids])]
|
||||
(reaction
|
||||
(let [ids (set @staged-ids)
|
||||
requests (get-in @db [:chats @chat-id :requests])]
|
||||
(remove #(ids (:message-id %)) requests))))))
|
||||
|
||||
(register-sub :get-requests-map
|
||||
(fn [db]
|
||||
|
|
|
@ -26,32 +26,34 @@
|
|||
(def min-scale 1)
|
||||
(def max-scale 1.3)
|
||||
|
||||
(defn button-animation [val to-value loop? answered?]
|
||||
(defn button-animation [val to-value loop? answered? staged?]
|
||||
(anim/anim-sequence
|
||||
[(anim/anim-delay
|
||||
(if (and @loop? (not @answered?))
|
||||
(if (and @loop? (or @staged? (not @answered?)))
|
||||
request-message-icon-scale-delay
|
||||
0))
|
||||
(anim/spring val {:toValue to-value})]))
|
||||
|
||||
(defn request-button-animation-logic
|
||||
[{:keys [to-value val loop? answered?] :as context}]
|
||||
[{:keys [to-value val loop? answered? staged?] :as context}]
|
||||
(anim/start
|
||||
(button-animation val to-value loop? answered?)
|
||||
#(if (and @loop? (not @answered?))
|
||||
(let [new-value (if (= to-value min-scale) max-scale min-scale)
|
||||
context' (assoc context :to-value new-value)]
|
||||
(request-button-animation-logic context'))
|
||||
(anim/start
|
||||
(button-animation val min-scale loop? answered?)))))
|
||||
(button-animation val to-value loop? answered? staged?)
|
||||
#(if (and @loop? (or @staged? (not @answered?)))
|
||||
(let [new-value (if (= to-value min-scale) max-scale min-scale)
|
||||
context' (assoc context :to-value new-value)]
|
||||
(request-button-animation-logic context'))
|
||||
(anim/start
|
||||
(button-animation val min-scale loop? answered? staged?)))))
|
||||
|
||||
(defn request-button [message-id command status-initialized? top-offset?]
|
||||
(let [scale-anim-val (anim/create-value min-scale)
|
||||
answered? (subscribe [:is-request-answered? message-id])
|
||||
staged? (subscribe [:staged-response? message-id])
|
||||
loop? (r/atom true)
|
||||
context {:to-value max-scale
|
||||
:val scale-anim-val
|
||||
:answered? answered?
|
||||
:staged? staged?
|
||||
:loop? loop?}]
|
||||
(r/create-class
|
||||
{:component-did-mount
|
||||
|
@ -78,11 +80,11 @@
|
|||
status-initialized? (subscribe [:get :status-module-initialized?])]
|
||||
(fn [{:keys [message-id content from incoming-group]}]
|
||||
(let [commands @commands-atom
|
||||
params (:params content)
|
||||
params (:params content)
|
||||
{:keys [command content]} (parse-command-request commands content)
|
||||
command (if (and params command)
|
||||
(merge command {:set-params params})
|
||||
command)]
|
||||
command (if (and params command)
|
||||
(merge command {:set-params params})
|
||||
command)]
|
||||
[view st/comand-request-view
|
||||
[touchable-highlight
|
||||
{:on-press (when (and (not @answered?) @status-initialized?)
|
||||
|
@ -92,13 +94,13 @@
|
|||
[text {:style st/command-request-from-text
|
||||
:font :default}
|
||||
from])
|
||||
[text {:style st/style-message-text
|
||||
[text {:style st/style-message-text
|
||||
:on-layout #(reset! top-offset {:specified? true
|
||||
:value (-> (.-nativeEvent %)
|
||||
(.-layout)
|
||||
(.-height)
|
||||
(.-height)
|
||||
(> 25))})
|
||||
:font :default}
|
||||
:font :default}
|
||||
content]]]
|
||||
(when (:request-text command)
|
||||
[view st/command-request-text-view
|
||||
|
|
|
@ -64,9 +64,20 @@
|
|||
(when status
|
||||
(call-module #(.startNode status on-result))))
|
||||
|
||||
(defonce account-creation? (atom false))
|
||||
|
||||
(defn create-account [password on-result]
|
||||
(when status
|
||||
(call-module #(.createAccount status password on-result))))
|
||||
(let [callback (fn [data]
|
||||
(reset! account-creation? true)
|
||||
(on-result data))]
|
||||
(swap! account-creation?
|
||||
(fn [creation?]
|
||||
(if-not creation?
|
||||
(do
|
||||
(call-module #(.createAccount status password callback))
|
||||
true)
|
||||
false))))))
|
||||
|
||||
(defn recover-account [passphrase password on-result]
|
||||
(when status
|
||||
|
|
Loading…
Reference in New Issue