mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
Merge pull request #7172 from BlueWallet/phook
REF: usePrivacy hook no longer needed
This commit is contained in:
commit
c86f2a2833
12 changed files with 39 additions and 84 deletions
|
@ -1,34 +0,0 @@
|
||||||
import { useEffect, useCallback } from 'react';
|
|
||||||
import { disallowScreenshot } from 'react-native-screen-capture';
|
|
||||||
import { useSettings } from './context/useSettings';
|
|
||||||
|
|
||||||
export const usePrivacy = () => {
|
|
||||||
const { isPrivacyBlurEnabled } = useSettings();
|
|
||||||
|
|
||||||
const enableBlur = useCallback(() => {
|
|
||||||
if (!isPrivacyBlurEnabled) return;
|
|
||||||
disallowScreenshot(true);
|
|
||||||
}, [isPrivacyBlurEnabled]);
|
|
||||||
|
|
||||||
const disableBlur = useCallback(() => {
|
|
||||||
disallowScreenshot(false);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// Apply privacy settings when the component mounts or when the setting changes
|
|
||||||
if (isPrivacyBlurEnabled) {
|
|
||||||
enableBlur();
|
|
||||||
} else {
|
|
||||||
disableBlur();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup: Re-enable screenshots when the component unmounts
|
|
||||||
return () => {
|
|
||||||
disableBlur();
|
|
||||||
};
|
|
||||||
}, [isPrivacyBlurEnabled, enableBlur, disableBlur]);
|
|
||||||
|
|
||||||
return { enableBlur, disableBlur };
|
|
||||||
};
|
|
||||||
|
|
||||||
export default usePrivacy;
|
|
|
@ -16,7 +16,7 @@ import { BlueText } from '../../BlueComponents';
|
||||||
import presentAlert from '../../components/Alert';
|
import presentAlert from '../../components/Alert';
|
||||||
import { DynamicQRCode } from '../../components/DynamicQRCode';
|
import { DynamicQRCode } from '../../components/DynamicQRCode';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ const SendCreate = () => {
|
||||||
const size = transaction.virtualSize();
|
const size = transaction.virtualSize();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { setOptions } = useNavigation();
|
const { setOptions } = useNavigation();
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
const styleHooks = StyleSheet.create({
|
const styleHooks = StyleSheet.create({
|
||||||
transactionDetailsTitle: {
|
transactionDetailsTitle: {
|
||||||
|
@ -48,11 +47,11 @@ const SendCreate = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('send/create - useEffect');
|
console.log('send/create - useEffect');
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
return () => {
|
return () => {
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
}, [disableBlur, enableBlur]);
|
}, []);
|
||||||
|
|
||||||
const exportTXN = useCallback(async () => {
|
const exportTXN = useCallback(async () => {
|
||||||
const fileName = `${Date.now()}.txn`;
|
const fileName = `${Date.now()}.txn`;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { DynamicQRCode } from '../../components/DynamicQRCode';
|
||||||
import SaveFileButton from '../../components/SaveFileButton';
|
import SaveFileButton from '../../components/SaveFileButton';
|
||||||
import { SquareButton } from '../../components/SquareButton';
|
import { SquareButton } from '../../components/SquareButton';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
import { ExportMultisigCoordinationSetupStackRootParamList } from '../../navigation/ExportMultisigCoordinationSetupStack';
|
import { ExportMultisigCoordinationSetupStackRootParamList } from '../../navigation/ExportMultisigCoordinationSetupStack';
|
||||||
|
@ -75,7 +75,7 @@ const ExportMultisigCoordinationSetup: React.FC = () => {
|
||||||
const wallet: TWallet | undefined = wallets.find(w => w.getID() === walletID);
|
const wallet: TWallet | undefined = wallets.find(w => w.getID() === walletID);
|
||||||
const dynamicQRCode = useRef<any>();
|
const dynamicQRCode = useRef<any>();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const stylesHook = StyleSheet.create({
|
const stylesHook = StyleSheet.create({
|
||||||
scrollViewContent: {
|
scrollViewContent: {
|
||||||
|
@ -99,7 +99,7 @@ const ExportMultisigCoordinationSetup: React.FC = () => {
|
||||||
dispatch({ type: ActionType.SET_LOADING, isLoading: true });
|
dispatch({ type: ActionType.SET_LOADING, isLoading: true });
|
||||||
|
|
||||||
const task = InteractionManager.runAfterInteractions(() => {
|
const task = InteractionManager.runAfterInteractions(() => {
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
if (wallet) {
|
if (wallet) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -125,7 +125,7 @@ const ExportMultisigCoordinationSetup: React.FC = () => {
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
task.cancel();
|
task.cancel();
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [walletID]),
|
}, [walletID]),
|
||||||
|
|
|
@ -18,8 +18,7 @@ import { AddWalletStackParamList } from '../../navigation/AddWalletStack';
|
||||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||||
import { THDWalletForWatchOnly, TWallet } from '../../class/wallets/types';
|
import { THDWalletForWatchOnly, TWallet } from '../../class/wallets/types';
|
||||||
import { navigate } from '../../NavigationService';
|
import { navigate } from '../../NavigationService';
|
||||||
import { keepAwake } from 'react-native-screen-capture';
|
import { keepAwake, disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
|
||||||
|
|
||||||
type RouteProps = RouteProp<AddWalletStackParamList, 'ImportWalletDiscovery'>;
|
type RouteProps = RouteProp<AddWalletStackParamList, 'ImportWalletDiscovery'>;
|
||||||
type NavigationProp = NativeStackNavigationProp<AddWalletStackParamList, 'ImportWalletDiscovery'>;
|
type NavigationProp = NativeStackNavigationProp<AddWalletStackParamList, 'ImportWalletDiscovery'>;
|
||||||
|
@ -54,7 +53,6 @@ const ImportWalletDiscovery: React.FC = () => {
|
||||||
const [selected, setSelected] = useState<number>(0);
|
const [selected, setSelected] = useState<number>(0);
|
||||||
const [progress, setProgress] = useState<string | undefined>();
|
const [progress, setProgress] = useState<string | undefined>();
|
||||||
const importing = useRef<boolean>(false);
|
const importing = useRef<boolean>(false);
|
||||||
const { disableBlur } = usePrivacy();
|
|
||||||
const bip39 = useMemo(() => {
|
const bip39 = useMemo(() => {
|
||||||
const hd = new HDSegwitBech32Wallet();
|
const hd = new HDSegwitBech32Wallet();
|
||||||
hd.setSecret(importText);
|
hd.setSecret(importText);
|
||||||
|
@ -147,7 +145,7 @@ const ImportWalletDiscovery: React.FC = () => {
|
||||||
const handleCustomDerivation = () => {
|
const handleCustomDerivation = () => {
|
||||||
task.current?.stop();
|
task.current?.stop();
|
||||||
keepAwake(false);
|
keepAwake(false);
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
navigation.navigate('ImportCustomDerivationPath', { importText, password });
|
navigation.navigate('ImportCustomDerivationPath', { importText, password });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { useNavigation, useRoute } from '@react-navigation/native';
|
||||||
import { BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native';
|
import { BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native';
|
||||||
import Button from '../../components/Button';
|
import Button from '../../components/Button';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ const PleaseBackup: React.FC = () => {
|
||||||
const wallet = wallets.find(w => w.getID() === walletID);
|
const wallet = wallets.find(w => w.getID() === walletID);
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
const stylesHook = StyleSheet.create({
|
const stylesHook = StyleSheet.create({
|
||||||
flex: {
|
flex: {
|
||||||
|
@ -38,10 +37,10 @@ const PleaseBackup: React.FC = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
|
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
return () => {
|
return () => {
|
||||||
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
|
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -41,7 +41,7 @@ import prompt from '../../helpers/prompt';
|
||||||
import { scanQrHelper } from '../../helpers/scan-qr';
|
import { scanQrHelper } from '../../helpers/scan-qr';
|
||||||
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
|
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
|
||||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import ActionSheet from '../ActionSheet';
|
import ActionSheet from '../ActionSheet';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
|
@ -78,7 +78,6 @@ const ViewEditMultisigCosigners: React.FC = () => {
|
||||||
Why the container view ? It was the easiest to get the ref for. No other reason.
|
Why the container view ? It was the easiest to get the ref for. No other reason.
|
||||||
*/
|
*/
|
||||||
const discardChangesRef = useRef<View>(null);
|
const discardChangesRef = useRef<View>(null);
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
const stylesHook = StyleSheet.create({
|
const stylesHook = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
|
@ -190,7 +189,7 @@ const ViewEditMultisigCosigners: React.FC = () => {
|
||||||
if (hasLoaded.current) return;
|
if (hasLoaded.current) return;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
|
|
||||||
const task = InteractionManager.runAfterInteractions(async () => {
|
const task = InteractionManager.runAfterInteractions(async () => {
|
||||||
if (!w.current) {
|
if (!w.current) {
|
||||||
|
@ -206,7 +205,7 @@ const ViewEditMultisigCosigners: React.FC = () => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
task.cancel();
|
task.cancel();
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ActivityIndicator, FlatList, StyleSheet, View, Platform, UIManager } fr
|
||||||
import { WatchOnlyWallet } from '../../class';
|
import { WatchOnlyWallet } from '../../class';
|
||||||
import { AddressItem } from '../../components/addresses/AddressItem';
|
import { AddressItem } from '../../components/addresses/AddressItem';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||||
import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList';
|
import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList';
|
||||||
|
@ -131,7 +131,6 @@ const WalletAddresses: React.FC = () => {
|
||||||
|
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { setOptions } = useExtendedNavigation<NavigationProps>();
|
const { setOptions } = useExtendedNavigation<NavigationProps>();
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
const stylesHook = StyleSheet.create({
|
const stylesHook = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
|
@ -177,12 +176,12 @@ const WalletAddresses: React.FC = () => {
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
getAddresses();
|
getAddresses();
|
||||||
return () => {
|
return () => {
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
}, [enableBlur, disableBlur, getAddresses]),
|
}, [getAddresses]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const data =
|
const data =
|
||||||
|
|
|
@ -8,7 +8,7 @@ import HandOffComponent from '../../components/HandOffComponent';
|
||||||
import QRCodeComponent from '../../components/QRCodeComponent';
|
import QRCodeComponent from '../../components/QRCodeComponent';
|
||||||
import SafeArea from '../../components/SafeArea';
|
import SafeArea from '../../components/SafeArea';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
import { HandOffActivityType } from '../../components/types';
|
import { HandOffActivityType } from '../../components/types';
|
||||||
|
@ -25,7 +25,6 @@ const WalletExport: React.FC = () => {
|
||||||
const wallet = wallets.find(w => w.getID() === walletID);
|
const wallet = wallets.find(w => w.getID() === walletID);
|
||||||
const [qrCodeSize, setQRCodeSize] = useState(90);
|
const [qrCodeSize, setQRCodeSize] = useState(90);
|
||||||
const appState = useRef(AppState.currentState);
|
const appState = useRef(AppState.currentState);
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const subscription = AppState.addEventListener('change', nextAppState => {
|
const subscription = AppState.addEventListener('change', nextAppState => {
|
||||||
|
@ -55,7 +54,7 @@ const WalletExport: React.FC = () => {
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
const task = InteractionManager.runAfterInteractions(async () => {
|
const task = InteractionManager.runAfterInteractions(async () => {
|
||||||
if (wallet) {
|
if (wallet) {
|
||||||
if (!wallet.getUserHasSavedExport()) {
|
if (!wallet.getUserHasSavedExport()) {
|
||||||
|
@ -67,7 +66,7 @@ const WalletExport: React.FC = () => {
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
task.cancel();
|
task.cancel();
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [wallet]),
|
}, [wallet]),
|
||||||
|
|
|
@ -29,7 +29,7 @@ import QRCodeComponent from '../../components/QRCodeComponent';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import confirm from '../../helpers/confirm';
|
import confirm from '../../helpers/confirm';
|
||||||
import prompt from '../../helpers/prompt';
|
import prompt from '../../helpers/prompt';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
import { scanQrHelper } from '../../helpers/scan-qr';
|
import { scanQrHelper } from '../../helpers/scan-qr';
|
||||||
|
@ -60,15 +60,14 @@ const WalletsAddMultisigStep2 = () => {
|
||||||
const [askPassphrase, setAskPassphrase] = useState(false);
|
const [askPassphrase, setAskPassphrase] = useState(false);
|
||||||
const openScannerButton = useRef();
|
const openScannerButton = useRef();
|
||||||
const data = useRef(new Array(n));
|
const data = useRef(new Array(n));
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
return () => {
|
return () => {
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
}, [disableBlur, enableBlur]),
|
}, []),
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { BlueButtonLink, BlueFormLabel, BlueFormMultiInput, BlueSpacing20 } from
|
||||||
import Button from '../../components/Button';
|
import Button from '../../components/Button';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import { scanQrHelper } from '../../helpers/scan-qr';
|
import { scanQrHelper } from '../../helpers/scan-qr';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import {
|
import {
|
||||||
DoneAndDismissKeyboardInputAccessory,
|
DoneAndDismissKeyboardInputAccessory,
|
||||||
|
@ -28,7 +28,6 @@ const WalletsImport = () => {
|
||||||
const [, setSpeedBackdoor] = useState(0);
|
const [, setSpeedBackdoor] = useState(0);
|
||||||
const [searchAccounts, setSearchAccounts] = useState(false);
|
const [searchAccounts, setSearchAccounts] = useState(false);
|
||||||
const [askPassphrase, setAskPassphrase] = useState(false);
|
const [askPassphrase, setAskPassphrase] = useState(false);
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -60,11 +59,11 @@ const WalletsImport = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
return () => {
|
return () => {
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
}, [disableBlur, enableBlur]);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (triggerImport) importButtonPressed();
|
if (triggerImport) importButtonPressed();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import CopyTextToClipboard from '../../components/CopyTextToClipboard';
|
||||||
import QRCodeComponent from '../../components/QRCodeComponent';
|
import QRCodeComponent from '../../components/QRCodeComponent';
|
||||||
import SafeArea from '../../components/SafeArea';
|
import SafeArea from '../../components/SafeArea';
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ const PleaseBackupLNDHub = () => {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const [qrCodeSize, setQRCodeSize] = useState(90);
|
const [qrCodeSize, setQRCodeSize] = useState(90);
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
const handleBackButton = useCallback(() => {
|
const handleBackButton = useCallback(() => {
|
||||||
navigation.getParent().pop();
|
navigation.getParent().pop();
|
||||||
|
@ -39,13 +38,13 @@ const PleaseBackupLNDHub = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
enableBlur();
|
disallowScreenshot(true);
|
||||||
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
|
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
|
||||||
return () => {
|
return () => {
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
|
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
|
||||||
};
|
};
|
||||||
}, [disableBlur, enableBlur, handleBackButton]);
|
}, [handleBackButton]);
|
||||||
|
|
||||||
const pop = () => navigation.getParent().pop();
|
const pop = () => navigation.getParent().pop();
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import CopyTextToClipboard from '../../components/CopyTextToClipboard';
|
||||||
import HandOffComponent from '../../components/HandOffComponent';
|
import HandOffComponent from '../../components/HandOffComponent';
|
||||||
import QRCodeComponent from '../../components/QRCodeComponent';
|
import QRCodeComponent from '../../components/QRCodeComponent';
|
||||||
import SafeArea from '../../components/SafeArea';
|
import SafeArea from '../../components/SafeArea';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { styles, useDynamicStyles } from './xpub.styles';
|
import { styles, useDynamicStyles } from './xpub.styles';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
|
@ -33,15 +33,14 @@ const WalletXpub: React.FC = () => {
|
||||||
const stylesHook = useDynamicStyles(); // This now includes the theme implicitly
|
const stylesHook = useDynamicStyles(); // This now includes the theme implicitly
|
||||||
const [qrCodeSize, setQRCodeSize] = useState<number>(90);
|
const [qrCodeSize, setQRCodeSize] = useState<number>(90);
|
||||||
const lastWalletIdRef = useRef<string | undefined>();
|
const lastWalletIdRef = useRef<string | undefined>();
|
||||||
const { enableBlur, disableBlur } = usePrivacy();
|
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
|
disallowScreenshot(true);
|
||||||
// Skip execution if walletID hasn't changed
|
// Skip execution if walletID hasn't changed
|
||||||
if (lastWalletIdRef.current === walletID) {
|
if (lastWalletIdRef.current === walletID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
enableBlur();
|
|
||||||
const task = InteractionManager.runAfterInteractions(async () => {
|
const task = InteractionManager.runAfterInteractions(async () => {
|
||||||
if (wallet) {
|
if (wallet) {
|
||||||
const walletXpub = wallet.getXpub();
|
const walletXpub = wallet.getXpub();
|
||||||
|
@ -57,9 +56,9 @@ const WalletXpub: React.FC = () => {
|
||||||
lastWalletIdRef.current = walletID;
|
lastWalletIdRef.current = walletID;
|
||||||
return () => {
|
return () => {
|
||||||
task.cancel();
|
task.cancel();
|
||||||
disableBlur();
|
disallowScreenshot(false);
|
||||||
};
|
};
|
||||||
}, [walletID, enableBlur, wallet, xpub, navigation, disableBlur]),
|
}, [walletID, wallet, xpub, navigation]),
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue