From a995591c9d7e850a12b75d060c8bcbd1b9f6b8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Tue, 7 Sep 2021 10:18:25 -0400 Subject: [PATCH 1/2] REF: Update Details button to match design --- components/AddressInput.js | 2 +- screen/send/confirm.js | 73 +++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/components/AddressInput.js b/components/AddressInput.js index 4fa63a290..ea830ec2e 100644 --- a/components/AddressInput.js +++ b/components/AddressInput.js @@ -54,7 +54,7 @@ const AddressInput = ({ style={styles.input} editable={!isLoading} onBlur={onBlurEditing} - autoCapitalize={false} + autoCapitalize="none" autoCorrect={false} keyboardType="url" /> diff --git a/screen/send/confirm.js b/screen/send/confirm.js index 4e16617fd..b27d0de74 100644 --- a/screen/send/confirm.js +++ b/screen/send/confirm.js @@ -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: () => ( + { + if (isBiometricUseCapableAndEnabled) { + if (!(await Biometric.unlockWithBiometrics())) { + return; + } + } + + navigate('CreateTransaction', { + fee, + recipients, + memo, + tx, + satoshiPerByte, + wallet, + feeSatoshi, + }); + }} + > + {loc.send.create_details} + + ), + }); + // 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)}) {isLoading ? : } - { - if (isBiometricUseCapableAndEnabled) { - if (!(await Biometric.unlockWithBiometrics())) { - return; - } - } - - navigate('CreateTransaction', { - fee, - recipients, - memo, - tx, - satoshiPerByte, - wallet, - feeSatoshi, - }); - }} - > - {loc.transactions.details_transaction_details} - @@ -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', From 5b5a9ba924a7e8f3d2efb0971cc917dd5cc479f5 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Tue, 7 Sep 2021 20:30:07 +0100 Subject: [PATCH 2/2] FIX: storage issues --- App.js | 4 ++++ blue_modules/notifications.js | 1 + blue_modules/storage-context.js | 6 +++++- screen/wallets/details.js | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/App.js b/App.js index 4912892b8..1fb5e3197 100644 --- a/App.js +++ b/App.js @@ -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(); diff --git a/blue_modules/notifications.js b/blue_modules/notifications.js index b68924104..4b037d263 100644 --- a/blue_modules/notifications.js +++ b/blue_modules/notifications.js @@ -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); diff --git a/blue_modules/storage-context.js b/blue_modules/storage-context.js index 6a7784735..05f0884c8 100644 --- a/blue_modules/storage-context.js +++ b/blue_modules/storage-context.js @@ -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()]); diff --git a/screen/wallets/details.js b/screen/wallets/details.js index 30216a096..e7889d212 100644 --- a/screen/wallets/details.js +++ b/screen/wallets/details.js @@ -200,7 +200,7 @@ const WalletDetails = () => { Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []); popToTop(); deleteWallet(wallet); - saveToDisk(); + saveToDisk(true); ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false }); };