Merge pull request #525 from status-im/bug/#524

Fix creation of multiple accounts
This commit is contained in:
adrian-tiberius 2016-12-01 12:56:26 +02:00 committed by GitHub
commit 2e0eab5210
3 changed files with 50 additions and 20 deletions

View File

@ -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]

View File

@ -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?))
(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?)))))
(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
@ -96,7 +98,7 @@
:on-layout #(reset! top-offset {:specified? true
:value (-> (.-nativeEvent %)
(.-layout)
(.-height)
(.-height)
(> 25))})
:font :default}
content]]]

View File

@ -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