Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 14 #122

Merged
merged 18 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix error navigating back on assets screen
  • Loading branch information
Danswar committed Jul 21, 2024
commit b9d9aabe20507ce61b5a62041173056184b040b6
17 changes: 10 additions & 7 deletions helpers/scan-qr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Helper function that navigates to ScanQR screen, and returns promise that will resolve with the result of a scan,
* and then navigates back. If QRCode scan was closed, promise resolves to null.
*
* @param navigateFunc {function}
* @param currentScreenName {string}
* @param showFileImportButton {boolean}
* @param navigateFunc {function} - navigation function from @react-navigation/native
* @param currentScreen {string | function} - name of the current screen or function that navigates to the current screen
* @param showFileImportButton {boolean} - whether to show file import button on the ScanQR screen
*
* @return {Promise<string>}
*/
module.exports = function scanQrHelper(
function scanQrHelper(
navigateFunc: (scr: string, params?: any) => void,
currentScreenName: string,
currentScreen: string | (() => void),
showFileImportButton = true,
): Promise<string | null> {
return new Promise(resolve => {
Expand All @@ -22,7 +22,10 @@ module.exports = function scanQrHelper(

params.onBarScanned = function (data: any) {
setTimeout(() => resolve(data.data || data), 1);
navigateFunc(currentScreenName);
if (typeof currentScreen === 'function') {
return currentScreen();
}
navigateFunc(currentScreen);
};

params.onDismiss = function () {
Expand All @@ -36,4 +39,4 @@ module.exports = function scanQrHelper(
});
};

export {};
export default scanQrHelper;
2 changes: 1 addition & 1 deletion screen/send/broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
} from '../../BlueComponents';
import BlueElectrum from '../../blue_modules/BlueElectrum';
import Notifications from '../../blue_modules/notifications';
import scanqr from '../../helpers/scan-qr';

const scanqr = require('../../helpers/scan-qr');

const BROADCAST_RESULT = Object.freeze({
none: 'Input transaction hex',
Expand Down
7 changes: 4 additions & 3 deletions screen/wallets/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import { AbstractHDElectrumWallet } from '../../class/wallets/abstract-hd-electrum-wallet';
import { LightningLdsWallet } from '../../class/wallets/lightning-lds-wallet';
import BoltCard from '../../class/boltcard';
import scanqrHelper from '../../helpers/scan-qr';

const scanqrHelper = require('../../helpers/scan-qr');
const fs = require('../../blue_modules/fs');
const BlueElectrum = require('../../blue_modules/BlueElectrum');
const currency = require('../../blue_modules/currency');
Expand Down Expand Up @@ -534,7 +534,8 @@ const Asset = ({ navigation }) => {
};

const onScanButtonPressed = () => {
scanqrHelper(navigate, name, false).then(d => onBarCodeRead(d));
const navigateBackHere = () => navigate(name, params);
scanqrHelper(navigate, navigateBackHere, false).then(d => onBarCodeRead(d));
};

const getItemLayout = (_, index) => ({
Expand All @@ -547,7 +548,7 @@ const Asset = ({ navigation }) => {
return wallet.getBoltcards().length > 0 ? navigate('BoltCardDetails') : navigate('AddBoltcard');
};

renderRightHeaderComponent = () => {
const renderRightHeaderComponent = () => {
switch (wallet.type) {
case LightningLdsWallet.type:
return (
Expand Down
2 changes: 1 addition & 1 deletion screen/wallets/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { LightningLdsWallet } from '../../class/wallets/lightning-lds-wallet';
import BoltCard from '../../class/boltcard';
import { TaprootLdsWallet, TaprootLdsWalletType } from '../../class/wallets/taproot-lds-wallet';
import scanqrHelper from '../../helpers/scan-qr';

const scanqrHelper = require('../../helpers/scan-qr');
const fs = require('../../blue_modules/fs');
const BlueElectrum = require('../../blue_modules/BlueElectrum');

Expand Down
2 changes: 1 addition & 1 deletion screen/wallets/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { isDesktop, isTablet } from '../../blue_modules/environment';
import BlueClipboard from '../../blue_modules/clipboard';
import navigationStyle from '../../components/navigationStyle';
import { TransactionListItem } from '../../components/TransactionListItem';
import scanqrHelper from '../../helpers/scan-qr';

const scanqrHelper = require('../../helpers/scan-qr');
const A = require('../../blue_modules/analytics');
const fs = require('../../blue_modules/fs');
const WalletsListSections = { CAROUSEL: 'CAROUSEL', TRANSACTIONS: 'TRANSACTIONS' };
Expand Down