* building send and replace settings context * adding translations * fixing double parse * adding spend and replace flags to send txs * adding listener to handle sar payments * add tx descripion handler for sar payments in restore * making sure sar key is fetched during app load * split toast manager and toast continer * adding tests * adding custom sar payment title to toast message * removing spark sdk navigation * adding sarPayment mark to transaction table * pass poolInfoRef from context to remove fetch if value is already set * remove spark naviagtion listener * fix btc -> usd swaps not calling sar * finalize spend and replace * fix timeout mismatch * adding usablePaymentMethod to narrow eligiblility * block requsets if account switches * remove duplicate storage and keep all referances to keyscontext * steralize writes to fix overlap issue
72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
import { useNavigation } from '@react-navigation/native';
|
|
import { useEffect, useRef } from 'react';
|
|
import { useAppStatus } from './appStatus';
|
|
import { crashlyticsLogReport } from '../app/functions/crashlyticsLogs';
|
|
import { useRootstockProvider } from './rootstockSwapContext';
|
|
import i18next from 'i18next';
|
|
import { useNodeContext } from './nodeContext';
|
|
|
|
export function RootstockNavigationListener() {
|
|
const navigation = useNavigation();
|
|
const { didGetToHomepage } = useAppStatus();
|
|
const { pendingNavigation, setPendingNavigation } = useRootstockProvider();
|
|
const isNavigating = useRef(false); // Use a ref for local state
|
|
|
|
useEffect(() => {
|
|
if (!pendingNavigation) return;
|
|
if (!didGetToHomepage) {
|
|
setPendingNavigation(null);
|
|
return;
|
|
}
|
|
if (isNavigating.current) return;
|
|
crashlyticsLogReport(`Navigating to confirm tx page in roostock listener`);
|
|
isNavigating.current = true;
|
|
|
|
setTimeout(() => {
|
|
requestAnimationFrame(() => {
|
|
navigation.navigate('ErrorScreen', {
|
|
errorMessage: i18next.t('errormessages.receivedRootstock'),
|
|
});
|
|
isNavigating.current = false;
|
|
console.log('cleaning up navigation for rootstock');
|
|
});
|
|
}, 100);
|
|
|
|
setPendingNavigation(null);
|
|
}, [pendingNavigation, didGetToHomepage]);
|
|
|
|
return null;
|
|
}
|
|
|
|
export function LiquidNavigationListener() {
|
|
const navigation = useNavigation();
|
|
const { didGetToHomepage } = useAppStatus();
|
|
const { pendingLiquidPayment, setPendingLiquidPayment } = useNodeContext();
|
|
const isNavigating = useRef(false); // Use a ref for local state
|
|
|
|
useEffect(() => {
|
|
if (!pendingLiquidPayment) return;
|
|
if (!didGetToHomepage) {
|
|
setPendingLiquidPayment(null);
|
|
return;
|
|
}
|
|
if (isNavigating.current) return;
|
|
crashlyticsLogReport(`Navigating to confirm tx page in liquid listener `);
|
|
isNavigating.current = true;
|
|
|
|
setTimeout(() => {
|
|
requestAnimationFrame(() => {
|
|
navigation.navigate('ErrorScreen', {
|
|
errorMessage: i18next.t('errormessages.receivedLiquid'),
|
|
});
|
|
isNavigating.current = false;
|
|
console.log('cleaning up navigation for liquid');
|
|
});
|
|
}, 100);
|
|
|
|
setPendingLiquidPayment(null);
|
|
}, [pendingLiquidPayment, didGetToHomepage]);
|
|
|
|
return null;
|
|
}
|