mirror of
https://github.com/status-im/status-react.git
synced 2025-01-11 19:44:47 +00:00
fix: not clearing network & web3-wallet on logout (#20886)
This commit is contained in:
parent
15a4219ef4
commit
fe54a25a3a
@ -13,15 +13,18 @@
|
|||||||
(native-module/logout)))
|
(native-module/logout)))
|
||||||
|
|
||||||
(rf/defn initialize-app-db
|
(rf/defn initialize-app-db
|
||||||
[{{:keys [keycard initials-avatar-font-file biometrics]
|
[{{:keys [keycard initials-avatar-font-file biometrics]
|
||||||
:network/keys [type]}
|
:network/keys [type status]
|
||||||
|
:wallet-connect/keys [web3-wallet]}
|
||||||
:db}]
|
:db}]
|
||||||
{:db (assoc db/app-db
|
{:db (assoc db/app-db
|
||||||
:network/type type
|
:network/type type
|
||||||
:initials-avatar-font-file initials-avatar-font-file
|
:network/status status
|
||||||
:keycard (dissoc keycard :secrets :pin :application-info)
|
:initials-avatar-font-file initials-avatar-font-file
|
||||||
:biometrics biometrics
|
:keycard (dissoc keycard :secrets :pin :application-info)
|
||||||
:syncing nil)})
|
:biometrics biometrics
|
||||||
|
:syncing nil
|
||||||
|
:wallet-connect/web3-wallet web3-wallet)})
|
||||||
|
|
||||||
(rf/defn logout-method
|
(rf/defn logout-method
|
||||||
{:events [::logout-method]}
|
{:events [::logout-method]}
|
||||||
|
@ -14,17 +14,20 @@
|
|||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/init
|
:wallet-connect/init
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
(let [network-status (:network/status db)]
|
(let [network-status (:network/status db)
|
||||||
(if (= network-status :online)
|
web3-wallet-missing? (-> db :wallet-connect/web3-wallet boolean not)]
|
||||||
{:fx [[:effects.wallet-connect/init
|
(if (and (= network-status :online) web3-wallet-missing?)
|
||||||
{:on-success #(rf/dispatch [:wallet-connect/on-init-success %])
|
(do (log/info "Initialising WalletConnect SDK")
|
||||||
:on-fail #(rf/dispatch [:wallet-connect/on-init-fail %])}]]}
|
{:fx [[:effects.wallet-connect/init
|
||||||
|
{:on-success #(rf/dispatch [:wallet-connect/on-init-success %])
|
||||||
|
:on-fail #(rf/dispatch [:wallet-connect/on-init-fail %])}]]})
|
||||||
;; NOTE: when offline, fetching persistent sessions only
|
;; NOTE: when offline, fetching persistent sessions only
|
||||||
{:fx [[:dispatch [:wallet-connect/fetch-persisted-sessions]]]}))))
|
{:fx [[:dispatch [:wallet-connect/fetch-persisted-sessions]]]}))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/on-init-success
|
:wallet-connect/on-init-success
|
||||||
(fn [{:keys [db]} [web3-wallet]]
|
(fn [{:keys [db]} [web3-wallet]]
|
||||||
|
(log/info "WalletConnect SDK initialisation successful")
|
||||||
{:db (assoc db :wallet-connect/web3-wallet web3-wallet)
|
{:db (assoc db :wallet-connect/web3-wallet web3-wallet)
|
||||||
:fx [[:dispatch [:wallet-connect/register-event-listeners]]
|
:fx [[:dispatch [:wallet-connect/register-event-listeners]]
|
||||||
[:dispatch [:wallet-connect/fetch-persisted-sessions]]]}))
|
[:dispatch [:wallet-connect/fetch-persisted-sessions]]]}))
|
||||||
@ -32,9 +35,9 @@
|
|||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/reload-on-network-change
|
:wallet-connect/reload-on-network-change
|
||||||
(fn [{:keys [db]} [is-connected?]]
|
(fn [{:keys [db]} [is-connected?]]
|
||||||
(let [logged-in? (-> db :profile/profile boolean)
|
(let [logged-in? (-> db :profile/profile boolean)]
|
||||||
web3-wallet-missing? (-> db :wallet-connect/web3-wallet boolean not)]
|
(when (and is-connected? logged-in?)
|
||||||
(when (and is-connected? logged-in? web3-wallet-missing?)
|
(log/info "Re-Initialising WalletConnect SDK due to network change")
|
||||||
{:fx [[:dispatch [:wallet-connect/init]]]}))))
|
{:fx [[:dispatch [:wallet-connect/init]]]}))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
@ -224,7 +227,10 @@
|
|||||||
|
|
||||||
(not version-supported?)
|
(not version-supported?)
|
||||||
(i18n/label :t/wallet-connect-version-not-supported
|
(i18n/label :t/wallet-connect-version-not-supported
|
||||||
{:version version}))}]]]}
|
{:version version})
|
||||||
|
|
||||||
|
:else
|
||||||
|
(i18n/label :t/something-went-wrong))}]]]}
|
||||||
{:fx [[:dispatch [:wallet-connect/pair scanned-text]]]}))))
|
{:fx [[:dispatch [:wallet-connect/pair scanned-text]]]}))))
|
||||||
|
|
||||||
;; We first load sessions from database, then we initiate a call to Wallet Connect SDK and
|
;; We first load sessions from database, then we initiate a call to Wallet Connect SDK and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user