fix protocol's initialization on js reloading
This commit is contained in:
parent
d29c6c3711
commit
55a5b96ad7
|
@ -128,7 +128,12 @@ public class GethModule extends ReactContextBaseJavaModule implements LifecycleE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void startNode(Callback callback) {
|
public void startNode(Callback callback, Callback onAlreadyRunning) {
|
||||||
|
|
||||||
|
if(GethService.isRunning()){
|
||||||
|
onAlreadyRunning.invoke();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Activity currentActivity = getCurrentActivity();
|
Activity currentActivity = getCurrentActivity();
|
||||||
|
|
||||||
|
|
|
@ -588,7 +588,9 @@
|
||||||
|
|
||||||
(register-handler :send-seen!
|
(register-handler :send-seen!
|
||||||
(after (fn [_ [_ chat-id message-id]]
|
(after (fn [_ [_ chat-id message-id]]
|
||||||
|
(when-not (= "console" chat-id))
|
||||||
(dispatch [:msg-seen chat-id message-id])))
|
(dispatch [:msg-seen chat-id message-id])))
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [_ [_ chat-id message-id]]
|
(fn [_ [_ chat-id message-id]]
|
||||||
(api/send-seen chat-id message-id))))
|
(when-not (= "console" chat-id)
|
||||||
|
(api/send-seen chat-id message-id)))))
|
||||||
|
|
|
@ -88,7 +88,9 @@
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(log/debug "Starting node")
|
(log/debug "Starting node")
|
||||||
(.startNode geth (fn [result] (node-started db result))))))
|
(.startNode geth
|
||||||
|
(fn [result] (node-started db result))
|
||||||
|
#(dispatch [:initialize-protocol])))))
|
||||||
|
|
||||||
(register-handler :crypt-initialized
|
(register-handler :crypt-initialized
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
|
|
||||||
(defn save-message
|
(defn save-message
|
||||||
;; todo remove chat-id parameter
|
;; todo remove chat-id parameter
|
||||||
[chat-id {:keys [msg-id content]
|
[chat-id {:keys [delivery-status msg-id content]
|
||||||
|
:or {delivery-status :pending}
|
||||||
:as message}]
|
:as message}]
|
||||||
(when-not (r/exists? :msgs :msg-id msg-id)
|
(when-not (r/exists? :msgs :msg-id msg-id)
|
||||||
(r/write
|
(r/write
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
message
|
message
|
||||||
{:chat-id chat-id
|
{:chat-id chat-id
|
||||||
:content content'
|
:content content'
|
||||||
|
:delivery-status delivery-status
|
||||||
:timestamp (timestamp)})]
|
:timestamp (timestamp)})]
|
||||||
(r/create :msgs message' true))))))
|
(r/create :msgs message' true))))))
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
(register-handler :initialize-protocol
|
(register-handler :initialize-protocol
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [db [_ account]]
|
(fn [{:keys [user-identity] :as db} [_ account]]
|
||||||
(init-protocol account (make-handler db)))))
|
(init-protocol (or account user-identity) (make-handler db)))))
|
||||||
|
|
||||||
(register-handler :protocol-initialized
|
(register-handler :protocol-initialized
|
||||||
(fn [db [_ identity]]
|
(fn [db [_ identity]]
|
||||||
|
|
Loading…
Reference in New Issue