reset shh keys on starting whisper, fix warnings related to outdated shh keys

This commit is contained in:
Roman Volosovskyi 2017-10-03 16:27:09 +02:00
parent 2763c87c40
commit cede095746
5 changed files with 21 additions and 5 deletions

View File

@ -27,7 +27,8 @@
[status-im.utils.listview :as lw] [status-im.utils.listview :as lw]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im.utils.money :as money])) [status-im.utils.money :as money]
[status-im.protocol.core :as protocol]))
(defonce drawer-atom (atom nil)) (defonce drawer-atom (atom nil))
(defn open-drawer! [] (.openDrawer @drawer-atom)) (defn open-drawer! [] (.openDrawer @drawer-atom))
@ -49,6 +50,8 @@
(defn navigate-to-accounts [] (defn navigate-to-accounts []
(close-drawer!) (close-drawer!)
(save-profile!) (save-profile!)
;; TODO(rasom): probably not the best place for this call
(protocol/stop-whisper!)
(rf/dispatch [:navigate-to :accounts])) (rf/dispatch [:navigate-to :accounts]))
(defview profile-picture [] (defview profile-picture []

View File

@ -68,6 +68,12 @@
(def stop-watching-all! f/remove-all-filters!) (def stop-watching-all! f/remove-all-filters!)
(def reset-all-pending-messages! d/reset-all-pending-messages!) (def reset-all-pending-messages! d/reset-all-pending-messages!)
(def reset-keys! shh-keys/reset-keys!)
(defn stop-whisper! []
(stop-watching-all!)
(reset-all-pending-messages!)
(reset-keys!))
(defn init-whisper! (defn init-whisper!
[{:keys [identity groups callback web3 [{:keys [identity groups callback web3
@ -75,8 +81,7 @@
:as options}] :as options}]
{:pre [(valid? ::options options)]} {:pre [(valid? ::options options)]}
(debug :init-whisper) (debug :init-whisper)
(stop-watching-all!) (stop-whisper!)
(d/reset-all-pending-messages!)
(let [listener-options {:web3 web3 (let [listener-options {:web3 web3
:identity identity :identity identity
:callback callback}] :callback callback}]

View File

@ -1,6 +1,6 @@
(ns status-im.protocol.handlers (ns status-im.protocol.handlers
(:require [status-im.utils.handlers :as u] (:require [status-im.utils.handlers :as u]
[re-frame.core :refer [dispatch after]] [re-frame.core :refer [dispatch after] :as re-frame]
[status-im.utils.handlers :refer [register-handler]] [status-im.utils.handlers :refer [register-handler]]
[status-im.data-store.contacts :as contacts] [status-im.data-store.contacts :as contacts]
[status-im.data-store.messages :as messages] [status-im.data-store.messages :as messages]
@ -22,6 +22,10 @@
[status-im.utils.web3-provider :as w3] [status-im.utils.web3-provider :as w3]
[status-im.utils.datetime :as time])) [status-im.utils.datetime :as time]))
(re-frame/reg-fx
:stop-whisper
(fn [] (protocol/stop-whisper!)))
(register-handler :initialize-protocol (register-handler :initialize-protocol
(fn [db [_ current-account-id ethereum-rpc-url]] (fn [db [_ current-account-id ethereum-rpc-url]]
(let [{:keys [public-key status updates-public-key (let [{:keys [public-key status updates-public-key

View File

@ -19,3 +19,6 @@
(fn [err res] (fn [err res]
(swap! password->keys assoc password res) (swap! password->keys assoc password res)
(callback res))))) (callback res)))))
(defn reset-keys! []
(reset! password->keys {}))

View File

@ -31,4 +31,5 @@
:connect-network :connect-network
(fn [cofx [_ network]] (fn [cofx [_ network]]
(merge (accounts-events/account-update cofx {:network network}) (merge (accounts-events/account-update cofx {:network network})
{:dispatch [:navigate-to-clean :accounts]}))) {:dispatch [:navigate-to-clean :accounts]
:stop-whisper nil})))