Clean up and fixes
This commit is contained in:
@@ -7,15 +7,14 @@ import React from 'react';
|
||||
import { Box, Text, useApp, useInput } from 'ink';
|
||||
import { NavigationProvider, useNavigation } from './hooks/useNavigation.js';
|
||||
import { AppProvider, useAppContext, useDialog, useStatus } from './hooks/useAppContext.js';
|
||||
import type { WalletController } from '../controllers/wallet-controller.js';
|
||||
import type { InvitationController } from '../controllers/invitation-controller.js';
|
||||
import type { AppConfig } from '../app.js';
|
||||
import { colors, logoSmall } from './theme.js';
|
||||
|
||||
// Screen imports (will be created)
|
||||
// Screen imports
|
||||
import { SeedInputScreen } from './screens/SeedInput.js';
|
||||
import { WalletStateScreen } from './screens/WalletState.js';
|
||||
import { TemplateListScreen } from './screens/TemplateList.js';
|
||||
import { ActionWizardScreen } from './screens/ActionWizard.js';
|
||||
import { ActionWizardScreen } from './screens/action-wizard/ActionWizardScreen.js';
|
||||
import { InvitationScreen } from './screens/Invitation.js';
|
||||
import { TransactionScreen } from './screens/Transaction.js';
|
||||
|
||||
@@ -23,8 +22,7 @@ import { TransactionScreen } from './screens/Transaction.js';
|
||||
* Props for the App component.
|
||||
*/
|
||||
interface AppProps {
|
||||
walletController: WalletController;
|
||||
invitationController: InvitationController;
|
||||
config: AppConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,6 +139,7 @@ function DialogOverlay(): React.ReactElement | null {
|
||||
function MainContent(): React.ReactElement {
|
||||
const { exit } = useApp();
|
||||
const { goBack, canGoBack } = useNavigation();
|
||||
const { screen } = useNavigation();
|
||||
const { dialog } = useDialog();
|
||||
const appContext = useAppContext();
|
||||
|
||||
@@ -158,6 +157,14 @@ function MainContent(): React.ReactElement {
|
||||
// Go back on Escape
|
||||
if (key.escape && canGoBack) {
|
||||
goBack();
|
||||
|
||||
// If we went back to the seed input screen, remove the current engine
|
||||
// TODO: This was to support going back to seed input then re-opening your seed, but there is a bug in the engine which prevents it from closing the current
|
||||
// storage instance, giving us an error about the database already being opened.
|
||||
if (screen === 'seed-input') {
|
||||
appContext.appService?.engine.stop();
|
||||
appContext.appService = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -181,19 +188,17 @@ function MainContent(): React.ReactElement {
|
||||
* Main App component.
|
||||
* Sets up providers and renders the main content.
|
||||
*/
|
||||
export function App({ walletController, invitationController }: AppProps): React.ReactElement {
|
||||
export function App({ config }: AppProps): React.ReactElement {
|
||||
const { exit } = useApp();
|
||||
|
||||
const handleExit = () => {
|
||||
// Cleanup controllers if needed
|
||||
walletController.stop();
|
||||
// Cleanup will be handled by React when components unmount
|
||||
exit();
|
||||
};
|
||||
|
||||
return (
|
||||
<AppProvider
|
||||
walletController={walletController}
|
||||
invitationController={invitationController}
|
||||
config={config}
|
||||
onExit={handleExit}
|
||||
>
|
||||
<NavigationProvider initialScreen="seed-input">
|
||||
|
||||
Reference in New Issue
Block a user