From a67ef43f6e099b6705d1726af5088971b87e8015 Mon Sep 17 00:00:00 2001 From: Keyan <34140557+huumn@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:15:39 -0600 Subject: [PATCH] listen for local storage wallet changes (#1552) --- wallets/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wallets/index.js b/wallets/index.js index 452ecfaa..fed2752f 100644 --- a/wallets/index.js +++ b/wallets/index.js @@ -41,7 +41,17 @@ function useLocalWallets () { }, [wallets, setWallets, me?.id]) useEffect(() => { + // listen for changes to any wallet config in local storage + // from any window with the same origin + const handleStorage = (event) => { + if (event.key.startsWith(getStorageKey(''))) { + loadWallets() + } + } + window.addEventListener('storage', handleStorage) + loadWallets() + return () => window.removeEventListener('storage', handleStorage) }, [loadWallets]) return { wallets, reloadLocalWallets: loadWallets, removeLocalWallets: removeWallets }