From 8c2a0a653b4cf35548c37f1f1774d9a61c7efa92 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Mon, 27 Mar 2023 11:05:45 -0400 Subject: [PATCH] FIX: If a watch isnt paired, dont bother syncing --- WatchConnectivity.ios.js | 10 ++++++---- ios/Podfile.lock | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WatchConnectivity.ios.js b/WatchConnectivity.ios.js index 098d68b2a..7022448f8 100644 --- a/WatchConnectivity.ios.js +++ b/WatchConnectivity.ios.js @@ -4,6 +4,7 @@ import { watchEvents, useReachability, useInstalled, + usePaired, transferCurrentComplicationUserInfo, } from 'react-native-watch-connectivity'; import { Chain } from './models/bitcoinUnits'; @@ -17,13 +18,14 @@ function WatchConnectivity() { const { walletsInitialized, wallets, fetchWalletTransactions, saveToDisk, txMetadata, preferredFiatCurrency } = useContext(BlueStorageContext); const isReachable = useReachability(); + const isPaired = usePaired(); const isInstalled = useInstalled(); // true | false const messagesListenerActive = useRef(false); const lastPreferredCurrency = useRef(FiatUnit.USD.endPointKey); useEffect(() => { let messagesListener = () => {}; - if (isInstalled && isReachable && walletsInitialized && messagesListenerActive.current === false) { + if (isPaired && isInstalled && isReachable && walletsInitialized && messagesListenerActive.current === false) { messagesListener = watchEvents.addListener('message', handleMessages); messagesListenerActive.current = true; } else { @@ -35,14 +37,14 @@ function WatchConnectivity() { messagesListenerActive.current = false; }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [walletsInitialized, isReachable, isInstalled]); + }, [walletsInitialized, isPaired, isReachable, isInstalled]); useEffect(() => { - if (isInstalled && isReachable && walletsInitialized) { + if (isPaired && isInstalled && isReachable && walletsInitialized) { sendWalletsToWatch(); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [walletsInitialized, wallets, isReachable, isInstalled]); + }, [walletsInitialized, wallets, isPaired, isReachable, isInstalled]); useEffect(() => { updateApplicationContext({ isWalletsInitialized: walletsInitialized, randomID: Math.floor(Math.random() * 11) }); diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ea2bf2246..2c859f518 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -396,7 +396,7 @@ PODS: - React - rn-ldk (0.8.4): - React-Core - - RNCAsyncStorage (1.17.12): + - RNCAsyncStorage (1.18.0): - React-Core - RNCClipboard (1.11.2): - React-Core @@ -764,7 +764,7 @@ SPEC CHECKSUMS: ReactNativeCameraKit: 9d46a5d7dd544ca64aa9c03c150d2348faf437eb RealmJS: 10958b8a9d1f3a981c1b50bdc1da8396002e75a4 rn-ldk: 0d8749d98cc5ce67302a32831818c116b67f7643 - RNCAsyncStorage: 09fc8595e6d6f6d5abf16b23a56b257d9c6b7c5b + RNCAsyncStorage: a46ee6bf15cf1ba863d0a47287236f9c95d5b213 RNCClipboard: 3f0451a8100393908bea5c5c5b16f96d45f30bfc RNCPushNotificationIOS: 87b8d16d3ede4532745e05b03c42cff33a36cc45 RNDefaultPreference: 08bdb06cfa9188d5da97d4642dac745218d7fb31