mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
FIX: If a watch isnt paired, dont bother syncing
This commit is contained in:
parent
6616513599
commit
8c2a0a653b
@ -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) });
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user