From 3f6e3b54083c8152f6b12bfe08d258d84ea4d3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Sat, 28 Aug 2021 03:08:58 -0400 Subject: [PATCH] REF: Throw alert --- loc/en.json | 2 +- screen/selftest.js | 6 ------ screen/settings/about.js | 11 +++++++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/loc/en.json b/loc/en.json index 2cbcfc4f9..e9fd5f904 100644 --- a/loc/en.json +++ b/loc/en.json @@ -246,7 +246,7 @@ "about_release_notes": "Release notes", "about_review": "Leave us a review", "about_selftest": "Run self-test", - "about_selftest_electrum_disabled": "Offline mode enabled. Unable to proceed with tests. Please disable Offline Mode and try again.", + "about_selftest_electrum_disabled": "Self testing is not available with Electrum Offline Mode. Please disable offline mode and try again.", "about_selftest_ok": "All internal tests have passed successfully. The wallet works well.", "about_sm_github": "GitHub", "about_sm_discord": "Discord Server", diff --git a/screen/selftest.js b/screen/selftest.js index 4b62989be..88825872b 100644 --- a/screen/selftest.js +++ b/screen/selftest.js @@ -15,7 +15,6 @@ import { HDAezeedWallet, SLIP39LegacyP2PKHWallet, } from '../class'; -import { BlueStorageContext } from '../blue_modules/storage-context'; const bitcoin = require('bitcoinjs-lib'); const BlueCrypto = require('react-native-blue-crypto'); const encryption = require('../blue_modules/encryption'); @@ -28,7 +27,6 @@ const styles = StyleSheet.create({ }); export default class Selftest extends Component { - static contextType = BlueStorageContext; constructor(props) { super(props); this.state = { @@ -57,10 +55,6 @@ export default class Selftest extends Component { // - if (this.context.isElectrumDisabled) { - throw new Error(loc.settings.about_selftest_electrum_disabled); - } - if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { await BlueElectrum.ping(); await BlueElectrum.waitTillConnected(); diff --git a/screen/settings/about.js b/screen/settings/about.js index b08375064..5420aef7e 100644 --- a/screen/settings/about.js +++ b/screen/settings/about.js @@ -1,4 +1,5 @@ -import React from 'react'; +/* global alert */ +import React, { useContext } from 'react'; import { TouchableOpacity, ScrollView, Linking, Image, View, Text, StyleSheet, useWindowDimensions, Platform } from 'react-native'; import { useNavigation, useTheme } from '@react-navigation/native'; import { Icon } from 'react-native-elements'; @@ -10,11 +11,13 @@ import navigationStyle from '../../components/navigationStyle'; import loc, { formatStringAddTwoWhiteSpaces } from '../../loc'; import Clipboard from '@react-native-clipboard/clipboard'; import Bugsnag from '@bugsnag/react-native'; +import { BlueStorageContext } from '../../blue_modules/storage-context'; const About = () => { const { navigate } = useNavigation(); const { colors } = useTheme(); const { width, height } = useWindowDimensions(); + const { isElectrumDisabled } = useContext(BlueStorageContext); const styles = StyleSheet.create({ copyToClipboard: { justifyContent: 'center', @@ -75,7 +78,11 @@ const About = () => { }; const handleOnSelfTestPress = () => { - navigate('Selftest'); + if (isElectrumDisabled) { + alert(loc.settings.about_selftest_electrum_disabled); + } else { + navigate('Selftest'); + } }; const handleOnLicensingPress = () => {