diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index cbd04d5d333..261a2c2d13c 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -31,6 +31,7 @@ "shh_generateSymKeyFromPassword" {} "shh_getSymKey" {} "shh_markTrustedPeer" {} + "shhext_startMessenger" {} "shhext_sendPairInstallation" {} "shhext_syncDevices" {} "shhext_requestMessages" {} diff --git a/src/status_im/mailserver/core.cljs b/src/status_im/mailserver/core.cljs index 13231eda907..6c10cb81837 100644 --- a/src/status_im/mailserver/core.cljs +++ b/src/status_im/mailserver/core.cljs @@ -808,7 +808,7 @@ :on-success #(log/debug "added mailserver-topic successfully") :on-failure - #(log/error "failed to delete mailserver topic" %)}) + #(log/error "failed to add mailserver topic" %)}) mailserver-topics)} (process-next-messages-request)))))))) diff --git a/src/status_im/mailserver/topics.cljs b/src/status_im/mailserver/topics.cljs index d02e1169541..5786f4b36ef 100644 --- a/src/status_im/mailserver/topics.cljs +++ b/src/status_im/mailserver/topics.cljs @@ -5,12 +5,14 @@ [status-im.utils.fx :as fx] [taoensso.timbre :as log])) -(defn calculate-last-request [{:keys [discovery?]} +(defn calculate-last-request [{:keys [negotiated? + discovery?]} {:keys [previous-last-request now-s]}] ;; New topic, if discovery we don't fetch history (if (and (nil? previous-last-request) - discovery?) + (or discovery? + negotiated?)) (- now-s 10) (max previous-last-request (- now-s constants/max-request-range)))) @@ -34,7 +36,7 @@ {::json-rpc/call [{:method "mailservers_addMailserverTopic" :params [mailserver-topic] :on-success #(log/debug "added mailserver-topic successfully") - :on-failure #(log/error "failed to delete mailserver topic" %)}]})) + :on-failure #(log/error "failed to add mailserver topic" %)}]})) (defn new-chat-ids? [previous-mailserver-topic new-mailserver-topic] (seq (clojure.set/difference (:chat-ids new-mailserver-topic) diff --git a/src/status_im/protocol/core.cljs b/src/status_im/protocol/core.cljs index 0cba94d1386..2b8cbd1af36 100644 --- a/src/status_im/protocol/core.cljs +++ b/src/status_im/protocol/core.cljs @@ -68,4 +68,4 @@ (not initialization-complete?) (assoc :initialization-protocol initialization-protocol))} (when initialization-complete? - (transport/init-whisper))))) + (transport/init-messenger))))) diff --git a/src/status_im/transport/core.cljs b/src/status_im/transport/core.cljs index 064b0120de5..6d4f2f19a3c 100644 --- a/src/status_im/transport/core.cljs +++ b/src/status_im/transport/core.cljs @@ -2,6 +2,7 @@ status-im.transport.core (:require [re-frame.core :as re-frame] + [status-im.ethereum.json-rpc :as json-rpc] [status-im.native-module.core :as status] [status-im.mailserver.core :as mailserver] [status-im.transport.message.core :as message] @@ -34,10 +35,23 @@ (fx/defn fetch-node-info-fx [cofx] {::fetch-node-info []}) +(fx/defn init-messenger + "We should only start receiving messages/processing topics once all the + initializiation is completed, otherwise we might receive messages/topics + when the state has not been properly initialized." + [cofx] + {::json-rpc/call [{:method "shhext_startMessenger" + :on-success #(do + (log/debug "messenger initialized") + (re-frame/dispatch [::init-whisper])) + :on-failure #(log/error "failed to init messenger")}]}) + (fx/defn init-whisper "Initialises whisper protocol by: - (optionally) initializing mailserver" + {:events [::init-whisper]} [cofx] + (log/debug "Initializing whisper") (fx/merge cofx (fetch-node-info-fx) (pairing/init) diff --git a/status-go-version.json b/status-go-version.json index dc01035a7ef..3db8129eda0 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.40.0", - "commit-sha1": "dc31c818fce6dbff6cfd76da09d901b0df742e2e", - "src-sha256": "1f0fp5c4lqnh244wcvbnl5i4p9fb0f3i0rjjvbiqwkz9zwwp3xlv" + "version": "v0.41.0", + "commit-sha1": "8931b14c4e40261e6161a3c776bf16cc0fdd1f3a", + "src-sha256": "16r3xbzhh3fljpx11yahm1r5xh4cyvggy5avg6smkpw9m93cb6f7" }