mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 23:08:07 +01:00
FIX: Pause QRCode during Export
This commit is contained in:
parent
9c07e45c09
commit
d88bb5b7b6
4 changed files with 28 additions and 37 deletions
|
@ -47,7 +47,7 @@ const writeFileAndExport = async function (filename, contents) {
|
|||
if (Platform.OS === 'ios') {
|
||||
const filePath = RNFS.TemporaryDirectoryPath + `/${filename}`;
|
||||
await RNFS.writeFile(filePath, contents);
|
||||
Share.open({
|
||||
await Share.open({
|
||||
url: 'file://' + filePath,
|
||||
saveToFiles: isDesktop,
|
||||
})
|
||||
|
@ -58,37 +58,12 @@ const writeFileAndExport = async function (filename, contents) {
|
|||
RNFS.unlink(filePath);
|
||||
});
|
||||
} else if (Platform.OS === 'android') {
|
||||
Alert.alert(
|
||||
loc._.file_save_title,
|
||||
|
||||
loc.formatString(loc._.file_save_location, { filePath: filename }),
|
||||
[
|
||||
{ text: loc._.cancel, onPress: () => {}, style: 'cancel' },
|
||||
{
|
||||
text: loc._.downloads_folder,
|
||||
onPress: () => {
|
||||
writeFileAndExportToAndroidDestionation({
|
||||
filename,
|
||||
contents,
|
||||
destinationLocalizedString: loc._.downloads_folder,
|
||||
destination: RNFS.DownloadDirectoryPath,
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
text: loc._.external_storage,
|
||||
onPress: async () => {
|
||||
writeFileAndExportToAndroidDestionation({
|
||||
filename,
|
||||
contents,
|
||||
destination: RNFS.ExternalStorageDirectoryPath,
|
||||
destinationLocalizedString: loc._.external_storage,
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
{ cancelable: true },
|
||||
);
|
||||
await writeFileAndExportToAndroidDestionation({
|
||||
filename,
|
||||
contents,
|
||||
destinationLocalizedString: loc._.downloads_folder,
|
||||
destination: RNFS.DownloadDirectoryPath,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ const PsbtMultisigQRCode = () => {
|
|||
const openScannerButton = useRef();
|
||||
const { psbtBase64, isShowOpenScanner } = useRoute().params;
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const dynamicQRCode = useRef();
|
||||
|
||||
const psbt = bitcoin.Psbt.fromBase64(psbtBase64);
|
||||
const stylesHook = StyleSheet.create({
|
||||
|
@ -64,15 +65,23 @@ const PsbtMultisigQRCode = () => {
|
|||
};
|
||||
|
||||
const exportPSBT = () => {
|
||||
dynamicQRCode.current?.stopAutoMove();
|
||||
setIsLoading(true);
|
||||
setTimeout(() => fs.writeFileAndExport(fileName, psbt.toBase64()).finally(() => setIsLoading(false)), 10);
|
||||
setTimeout(
|
||||
() =>
|
||||
fs.writeFileAndExport(fileName, psbt.toBase64()).finally(() => {
|
||||
setIsLoading(false);
|
||||
dynamicQRCode.current?.startAutoMove();
|
||||
}),
|
||||
10,
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeBlueArea style={stylesHook.root}>
|
||||
<ScrollView centerContent contentContainerStyle={styles.scrollViewContent}>
|
||||
<View style={[styles.modalContentShort, stylesHook.modalContentShort]}>
|
||||
<DynamicQRCode value={psbt.toHex()} />
|
||||
<DynamicQRCode value={psbt.toHex()} ref={dynamicQRCode} />
|
||||
{!isShowOpenScanner && (
|
||||
<>
|
||||
<BlueSpacing20 />
|
||||
|
|
|
@ -41,6 +41,7 @@ const PsbtWithHardwareWallet = () => {
|
|||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [txHex, setTxHex] = useState(route.params.txhex);
|
||||
const openScannerButton = useRef();
|
||||
const dynamicQRCode = useRef();
|
||||
|
||||
const stylesHook = StyleSheet.create({
|
||||
root: {
|
||||
|
@ -185,7 +186,10 @@ const PsbtWithHardwareWallet = () => {
|
|||
|
||||
const exportPSBT = () => {
|
||||
const fileName = `${Date.now()}.psbt`;
|
||||
fs.writeFileAndExport(fileName, typeof psbt === 'string' ? psbt : psbt.toBase64());
|
||||
dynamicQRCode.current?.stopAutoMove();
|
||||
fs.writeFileAndExport(fileName, typeof psbt === 'string' ? psbt : psbt.toBase64()).finally(() => {
|
||||
dynamicQRCode.current?.startAutoMove();
|
||||
});
|
||||
};
|
||||
|
||||
const openSignedTransaction = async () => {
|
||||
|
@ -237,7 +241,7 @@ const PsbtWithHardwareWallet = () => {
|
|||
<Text testID="PSBTHex" style={styles.hidden}>
|
||||
{psbt.toHex()}
|
||||
</Text>
|
||||
<DynamicQRCode value={psbt.toHex()} />
|
||||
<DynamicQRCode value={psbt.toHex()} ref={dynamicQRCode} />
|
||||
<BlueSpacing20 />
|
||||
<SecondButton
|
||||
testID="PsbtTxScanButton"
|
||||
|
|
|
@ -17,6 +17,7 @@ const ExportMultisigCoordinationSetup = () => {
|
|||
const { wallets } = useContext(BlueStorageContext);
|
||||
const wallet = wallets.find(w => w.getID() === walletId);
|
||||
const qrCodeContents = useRef();
|
||||
const dynamicQRCode = useRef();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [isShareButtonTapped, setIsShareButtonTapped] = useState(false);
|
||||
const { goBack } = useNavigation();
|
||||
|
@ -37,9 +38,11 @@ const ExportMultisigCoordinationSetup = () => {
|
|||
|
||||
const exportTxtFile = async () => {
|
||||
setIsShareButtonTapped(true);
|
||||
dynamicQRCode.current?.stopAutoMove();
|
||||
setTimeout(() => {
|
||||
fs.writeFileAndExport(wallet.getLabel() + '.txt', wallet.getXpub()).finally(() => {
|
||||
setIsShareButtonTapped(false);
|
||||
dynamicQRCode.current?.startAutoMove();
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
@ -79,7 +82,7 @@ const ExportMultisigCoordinationSetup = () => {
|
|||
<BlueText style={[styles.type, stylesHook.type]}>{wallet.getLabel()}</BlueText>
|
||||
</View>
|
||||
<BlueSpacing20 />
|
||||
<DynamicQRCode value={qrCodeContents.current} />
|
||||
<DynamicQRCode value={qrCodeContents.current} ref={dynamicQRCode} />
|
||||
<BlueSpacing20 />
|
||||
{isShareButtonTapped ? (
|
||||
<ActivityIndicator />
|
||||
|
|
Loading…
Add table
Reference in a new issue