From e4f55caa623f632f4c933225a9a7cc83e7b5d2b2 Mon Sep 17 00:00:00 2001 From: First-Terraner Date: Sat, 30 Mar 2024 12:52:20 +0100 Subject: [PATCH] add restoreSuccess screen component --- src/components/hooks/Restore.tsx | 7 ++++--- src/components/nav/Navigator.tsx | 2 ++ src/model/nav.ts | 11 +++++++++++ src/screens/Dashboard.tsx | 30 ++++++++++++++---------------- src/screens/Payment/Success.tsx | 3 --- src/screens/Restore/Success.tsx | 18 ++++++------------ 6 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/components/hooks/Restore.tsx b/src/components/hooks/Restore.tsx index 4e0295f7..953d10b7 100644 --- a/src/components/hooks/Restore.tsx +++ b/src/components/hooks/Restore.tsx @@ -70,10 +70,11 @@ export function useRestore({ from, to, mintUrl, keysetId, mnemonic, comingFromOn end: to ?? RESTORE_INTERVAL, overshoot: 0, }) - navigation.navigate('success', { + navigation.navigate('restoreSuccess', { mint: mintUrl, + keysetID: keysetId, + cycle: { start: restored.start, end: restored.end }, amount: bal, - isRestored: true, comingFromOnboarding, }) } catch (e) { @@ -145,7 +146,7 @@ export function useRestore({ from, to, mintUrl, keysetId, mnemonic, comingFromOn } } void restore() - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return { ...restored } diff --git a/src/components/nav/Navigator.tsx b/src/components/nav/Navigator.tsx index 659cd27c..0e08a6c7 100644 --- a/src/components/nav/Navigator.tsx +++ b/src/components/nav/Navigator.tsx @@ -39,6 +39,7 @@ import RecoveringScreen from '@screens/Restore/Recovering' import RestoreWarningScreen from '@screens/Restore/RestoreWarning' import SeedScreen from '@screens/Restore/Seed' import SelectRecoveryMintScreen from '@screens/Restore/SelectRecoveryMint' +import RestoreSuccess from '@screens/Restore/Success' import Settings from '@screens/Settings' import AboutSettings from '@screens/Settings/About' import ContactsSettings from '@screens/Settings/Contacts' @@ -197,6 +198,7 @@ export default function Navigator({ + ) diff --git a/src/model/nav.ts b/src/model/nav.ts index 638a0783..985d8032 100644 --- a/src/model/nav.ts +++ b/src/model/nav.ts @@ -246,6 +246,16 @@ export type RootStackParamList = { 'Restore warning': { comingFromOnboarding?: boolean } + restoreSuccess: { + amount: number + mint: string + keysetID: string + cycle: { + start: number + end: number + } + comingFromOnboarding?: boolean + } } export type TRouteString = 'dashboard' | 'mints' | 'Address book' | 'Settings' @@ -297,6 +307,7 @@ export type IDerivingPageProps = NativeStackScreenProps export type ISelectRecoveryMintPageProps = NativeStackScreenProps export type IRestoreWarningPageProps = NativeStackScreenProps +export type IRestoreSuccessPageProps = NativeStackScreenProps export type TBottomNavProps = TNostrOnboardingPageProps | TDashboardPageProps | diff --git a/src/screens/Dashboard.tsx b/src/screens/Dashboard.tsx index bcb3aa0a..0c788342 100644 --- a/src/screens/Dashboard.tsx +++ b/src/screens/Dashboard.tsx @@ -308,13 +308,12 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) { color={hi[highlight]} onPress={() => { // setModal(prev => ({ ...prev, sendOpts: true })) - navigation.navigate('Recovering', { - from: 500, - to: 550, - mintUrl: 'https://testnut.cashu.space', - keysetId: 'asfdafh8u2h3', - mnemonic: '', - comingFromOnboarding: false, + navigation.navigate('restoreSuccess', { + mint: 'https://testnut.cashu.space', + keysetID: 'jkasfhgkjg', + cycle: { start: 300, end: 350 }, + amount: 100, + comingFromOnboarding: true, }) }} /> @@ -324,15 +323,14 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) { txt={t('mint')} color={hi[highlight]} onPress={() => { - navigation.navigate('mints') - // navigation.navigate('Recovering', { - // from: 500, - // to: 550, - // mintUrl: 'https://testnut.cashu.space', - // keysetId: 'asfdafh8u2h3', - // mnemonic: '', - // comingFromOnboarding: false, - // }) + // navigation.navigate('mints') + navigation.navigate('restoreSuccess', { + mint: 'https://testnut.cashu.space', + keysetID: 'jkasfhgkjg', + cycle: { start: 300, end: 350 }, + amount: 100, + comingFromOnboarding: true, + }) }} /> } diff --git a/src/screens/Payment/Success.tsx b/src/screens/Payment/Success.tsx index 76b7ff3b..9586788e 100644 --- a/src/screens/Payment/Success.tsx +++ b/src/screens/Payment/Success.tsx @@ -7,7 +7,6 @@ import { preventBack } from '@nav/utils' import ProfilePic from '@screens/Addressbook/ProfilePic' import { useThemeContext } from '@src/context/Theme' import { NS } from '@src/i18n' -import { l } from '@src/logger' import { formatSatStr, isNum, vib } from '@util' import LottieView from 'lottie-react-native' import { useEffect } from 'react' @@ -44,8 +43,6 @@ export default function SuccessPage({ navigation, route }: TSuccessPageProps) { return () => navigation.removeListener('beforeRemove', backHandler) }, [navigation]) - l({ amount, memo, fee, mint, isClaim, isMelt, nostr, isScanned }) - return ( {nostr && nostr.contact && nostr.contact.picture ? diff --git a/src/screens/Restore/Success.tsx b/src/screens/Restore/Success.tsx index 692f5e0e..5e5062d9 100644 --- a/src/screens/Restore/Success.tsx +++ b/src/screens/Restore/Success.tsx @@ -86,7 +86,12 @@ export default function RestoreSuccess({ navigation, route }: IRestoreSuccessPag if (comingFromOnboarding) { return navigation.navigate('auth', { pinHash: '' }) } - return navigation.navigate('dashboard') + return navigation.navigate('success', { + mint, + amount, + isRestored: true, + comingFromOnboarding + }) }} /> @@ -94,17 +99,6 @@ export default function RestoreSuccess({ navigation, route }: IRestoreSuccessPag ) } -/* - -navigation.navigate('success', { - mint: mintUrl, - amount: bal, - isRestored: true, - comingFromOnboarding, - }) - -*/ - const styles = ScaledSheet.create({ container: { paddingTop: '60@s',