Merge branch 'master' into hookconfirm

This commit is contained in:
Marcos Rodriguez Vélez 2021-09-07 16:44:13 -04:00
commit f0d3c7c939
6 changed files with 53 additions and 35 deletions

4
App.js
View file

@ -190,6 +190,10 @@ const App = () => {
* @private
*/
const processPushNotifications = async () => {
if (!walletsInitialized) {
console.log('not processing push notifications because wallets are not initialized');
return;
}
await new Promise(resolve => setTimeout(resolve, 200));
// sleep needed as sometimes unsuspend is faster than notification module actually saves notifications to async storage
const notifications2process = await Notifications.getStoredNotifications();

View file

@ -60,6 +60,7 @@ function Notifications(props) {
if (notification.data && notification.data.data) Object.assign(payload, notification.data.data);
delete payload.data;
// ^^^ weird, but sometimes payload data is not in `data` but in root level
console.log('got push notification', payload);
await Notifications.addNotification(payload);

View file

@ -35,7 +35,11 @@ export const BlueStorageProvider = ({ children }) => {
return BlueApp.setIsHandoffEnabled(value);
};
const saveToDisk = async () => {
const saveToDisk = async (force = false) => {
if (BlueApp.getWallets().length === 0 && !force) {
console.log('not saving empty wallets array');
return;
}
BlueApp.tx_metadata = txMetadata;
await BlueApp.saveToDisk();
setWallets([...BlueApp.getWallets()]);

View file

@ -54,7 +54,7 @@ const AddressInput = ({
style={styles.input}
editable={!isLoading}
onBlur={onBlurEditing}
autoCapitalize={false}
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
/>

View file

@ -33,7 +33,7 @@ const Confirm = () => {
const wallet = wallets.find(wallet => wallet.getID() === walletID);
const payjoinUrl = wallet.allowPayJoin() ? params.payjoinUrl : false;
const feeSatoshi = new Bignumber(fee).multipliedBy(100000000).toNumber();
const { navigate } = useNavigation();
const { navigate, setOptions } = useNavigation();
const { colors } = useTheme();
const stylesHook = StyleSheet.create({
transactionDetailsTitle: {
@ -55,10 +55,6 @@ const Confirm = () => {
root: {
backgroundColor: colors.elevated,
},
txText: {
color: colors.feeText,
},
payjoinWrapper: {
backgroundColor: colors.buttonDisabledBackgroundColor,
},
@ -71,6 +67,38 @@ const Confirm = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
setOptions({
headerRight: () => (
<TouchableOpacity
accessibilityRole="button"
testID="TransactionDetailsButton"
style={styles.txDetails}
onPress={async () => {
if (isBiometricUseCapableAndEnabled) {
if (!(await Biometric.unlockWithBiometrics())) {
return;
}
}
navigate('CreateTransaction', {
fee,
recipients,
memo,
tx,
satoshiPerByte,
wallet,
feeSatoshi,
});
}}
>
<Text style={[styles.txText, stylesHook.valueUnit]}>{loc.send.create_details}</Text>
</TouchableOpacity>
),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [colors, fee, feeSatoshi, isBiometricUseCapableAndEnabled, memo, recipients, satoshiPerByte, tx, wallet]);
/**
* we need to look into `recipients`, find destination address and return its outputScript
* (needed for payjoin)
@ -234,30 +262,6 @@ const Confirm = () => {
{loc.send.create_fee}: {formatBalance(feeSatoshi, BitcoinUnit.BTC)} ({currency.satoshiToLocalCurrency(feeSatoshi)})
</Text>
{isLoading ? <ActivityIndicator /> : <BlueButton disabled={isElectrumDisabled} onPress={send} title={loc.send.confirm_sendNow} />}
<TouchableOpacity
accessibilityRole="button"
testID="TransactionDetailsButton"
style={styles.txDetails}
onPress={async () => {
if (isBiometricUseCapableAndEnabled) {
if (!(await Biometric.unlockWithBiometrics())) {
return;
}
}
navigate('CreateTransaction', {
fee,
recipients,
memo,
tx,
satoshiPerByte,
wallet,
feeSatoshi,
});
}}
>
<Text style={[styles.txText, stylesHook.txText]}>{loc.transactions.details_transaction_details}</Text>
</TouchableOpacity>
</BlueCard>
</View>
</SafeBlueArea>
@ -337,12 +341,17 @@ const styles = StyleSheet.create({
alignSelf: 'center',
},
txDetails: {
marginTop: 16,
backgroundColor: '#EEF0F4',
alignItems: 'center',
justifyContent: 'center',
marginRight: 16,
width: 80,
borderRadius: 8,
height: 38,
},
txText: {
fontSize: 15,
fontWeight: '500',
alignSelf: 'center',
fontWeight: '600',
},
payjoinWrapper: {
flexDirection: 'row',

View file

@ -200,7 +200,7 @@ const WalletDetails = () => {
Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []);
popToTop();
deleteWallet(wallet);
saveToDisk();
saveToDisk(true);
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
};