FIX: correct popToTop

This commit is contained in:
Marcos Rodriguez Velez 2024-06-06 13:11:08 -04:00
parent b78bf8c1fc
commit d8dcdbceaf
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
8 changed files with 15 additions and 22 deletions

View file

@ -1,5 +1,3 @@
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import React, { useReducer } from 'react';
import { ScrollView } from 'react-native';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
@ -9,6 +7,7 @@ import Button from '../components/Button';
import prompt from '../helpers/prompt';
import loc from '../loc';
import { useStorage } from '../hooks/context/useStorage';
import { popToTop } from '../NavigationService';
// Action Types
const SET_LOADING = 'SET_LOADING';
@ -39,7 +38,6 @@ function reducer(state: State, action: Action): State {
const PlausibleDeniability: React.FC = () => {
const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useStorage();
const [state, dispatch] = useReducer(reducer, initialState);
const navigation = useNavigation<NativeStackNavigationProp<Record<string, object | undefined>>>();
const handleOnCreateFakeStorageButtonPressed = async () => {
dispatch({ type: SET_LOADING, payload: true });
@ -66,7 +64,7 @@ const PlausibleDeniability: React.FC = () => {
resetWallets();
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
presentAlert({ message: loc.plausibledeniability.success });
navigation.popToTop();
popToTop();
} catch {
dispatch({ type: SET_LOADING, payload: false });
}

View file

@ -173,6 +173,4 @@ const styles = StyleSheet.create({
LnurlAuth.navigationOptions = navigationStyle({
title: '',
closeButton: true,
closeButtonFunc: ({ navigation }) => navigation.getParent().popToTop(),
});

View file

@ -1,14 +1,14 @@
import React, { Component } from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Image, Linking, ScrollView, StyleSheet, View } from 'react-native';
import { BlueButtonLink, BlueCard, BlueLoading, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents';
import Lnurl from '../../class/lnurl';
import Button from '../../components/Button';
import SafeArea from '../../components/SafeArea';
import loc from '../../loc';
import { SuccessView } from '../send/success';
import { popToTop } from '../../NavigationService';
export default class LnurlPaySuccess extends Component {
constructor(props) {
@ -119,7 +119,7 @@ export default class LnurlPaySuccess extends Component {
) : (
<Button
onPress={() => {
this.props.navigation.getParent().popToTop();
popToTop();
}}
title={loc.send.success_done}
/>

View file

@ -1,7 +1,5 @@
import React, { useCallback, useEffect, useReducer } from 'react';
import { Alert, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
import { StackActions } from '@react-navigation/native';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents';
import presentAlert from '../../components/Alert';
@ -12,6 +10,7 @@ import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
import loc from '../../loc';
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
import { useStorage } from '../../hooks/context/useStorage';
import { popToTop } from '../../NavigationService';
enum ActionType {
SetLoading = 'SET_LOADING',
@ -58,7 +57,7 @@ const EncryptStorage = () => {
const { isStorageEncrypted, encryptStorage, decryptStorage, saveToDisk } = useStorage();
const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType } = useBiometrics();
const [state, dispatch] = useReducer(reducer, initialState);
const { navigate, dispatch: navigationDispatch } = useExtendedNavigation();
const { navigate } = useExtendedNavigation();
const { colors } = useTheme();
const styleHooks = StyleSheet.create({
@ -84,10 +83,6 @@ const EncryptStorage = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const popToTop = () => {
navigationDispatch(StackActions.popToTop());
};
const handleDecryptStorage = async () => {
dispatch({ type: ActionType.SetCurrentLoadingSwitch, payload: 'decrypt' });
const password = await prompt(loc.settings.password, loc._.storage_is_encrypted).catch(() => {

View file

@ -25,6 +25,7 @@ import SafeArea from '../../components/SafeArea';
import { BlueCurrentTheme } from '../../components/themes';
import loc from '../../loc';
import { StorageContext } from '../../components/Context/StorageProvider';
import { popToTop } from '../../NavigationService';
const styles = StyleSheet.create({
root: {
@ -108,7 +109,7 @@ export default class CPFP extends Component {
this.context.txMetadata[this.state.newTxid] = { memo: 'Child pays for parent (CPFP)' };
Notifications.majorTomToGroundControl([], [], [this.state.newTxid]);
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
this.props.navigation.navigate('Success', { onDonePressed: () => popToTop(), amount: undefined });
}
async componentDidMount() {

View file

@ -9,6 +9,7 @@ import SafeArea from '../../components/SafeArea';
import loc from '../../loc';
import CPFP from './CPFP';
import { StorageContext } from '../../components/Context/StorageProvider';
import { popToTop } from '../../NavigationService';
const styles = StyleSheet.create({
root: {
@ -68,7 +69,7 @@ export default class RBFBumpFee extends CPFP {
this.context.txMetadata[this.state.newTxid] = this.context.txMetadata[this.state.txid];
}
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
this.props.navigation.navigate('Success', { onDonePressed: () => popToTop(), amount: undefined });
}
render() {
@ -108,7 +109,6 @@ export default class RBFBumpFee extends CPFP {
RBFBumpFee.propTypes = {
navigation: PropTypes.shape({
popToTop: PropTypes.func,
navigate: PropTypes.func,
state: PropTypes.shape({
params: PropTypes.shape({

View file

@ -9,6 +9,7 @@ import SafeArea from '../../components/SafeArea';
import loc from '../../loc';
import CPFP from './CPFP';
import { StorageContext } from '../../components/Context/StorageProvider';
import { popToTop } from '../../NavigationService';
export default class RBFCancel extends CPFP {
static contextType = StorageContext;
@ -71,7 +72,7 @@ export default class RBFCancel extends CPFP {
this.context.txMetadata[this.state.newTxid].memo = 'Cancelled transaction';
}
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
this.props.navigation.navigate('Success', { onDonePressed: () => popToTop(), amount: undefined });
}
render() {
@ -111,7 +112,6 @@ export default class RBFCancel extends CPFP {
RBFCancel.propTypes = {
navigation: PropTypes.shape({
popToTop: PropTypes.func,
navigate: PropTypes.func,
state: PropTypes.shape({
params: PropTypes.shape({

View file

@ -47,6 +47,7 @@ import loc, { formatBalanceWithoutSuffix } from '../../loc';
import { BitcoinUnit, Chain } from '../../models/bitcoinUnits';
import { useSettings } from '../../hooks/context/useSettings';
import { useStorage } from '../../hooks/context/useStorage';
import { popToTop } from '../../NavigationService';
const styles = StyleSheet.create({
scrollViewContent: {
@ -119,7 +120,7 @@ const WalletDetails = () => {
const { isAdvancedModeEnabled } = useSettings();
const [isBIP47Enabled, setIsBIP47Enabled] = useState(wallet.isBIP47Enabled());
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
const { goBack, setOptions, popToTop, navigate } = useExtendedNavigation();
const { goBack, setOptions, navigate } = useExtendedNavigation();
const { colors } = useTheme();
const [masterFingerprint, setMasterFingerprint] = useState();
const walletTransactionsLength = useMemo(() => wallet.getTransactions().length, [wallet]);