fix protocol's initialization on js reloading
Former-commit-id: 55a5b96ad7
This commit is contained in:
parent
02c2d4deae
commit
aa89c0f85d
|
@ -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))))))
|
||||||
|
|
||||||
|
@ -49,13 +51,13 @@
|
||||||
(defn get-messages
|
(defn get-messages
|
||||||
([chat-id] (get-messages chat-id 0))
|
([chat-id] (get-messages chat-id 0))
|
||||||
([chat-id from]
|
([chat-id from]
|
||||||
(->> (-> (r/get-by-field :msgs :chat-id chat-id)
|
(->> (-> (r/get-by-field :msgs :chat-id chat-id)
|
||||||
(r/sorted :timestamp :desc)
|
(r/sorted :timestamp :desc)
|
||||||
(r/page from (+ from c/default-number-of-messages))
|
(r/page from (+ from c/default-number-of-messages))
|
||||||
(r/collection->map))
|
(r/collection->map))
|
||||||
(into '())
|
(into '())
|
||||||
reverse
|
reverse
|
||||||
(keep (fn [{:keys [content-type] :as message}]
|
(keep (fn [{:keys [content-type] :as message}]
|
||||||
(if (command-type? content-type)
|
(if (command-type? content-type)
|
||||||
(update message :content str-to-map)
|
(update message :content str-to-map)
|
||||||
message))))))
|
message))))))
|
||||||
|
|
|
@ -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