feat(tauri): Initialize Context in background (#59)

This PR does the following:
- The Context (including Bitcoin wallet, Monero wallet, ...) is initialized in the background. This allows the window to be displayed instantly upon startup.
- Host sends events to Guest about progress of Context initialization. Those events are used to display an alert in the navigation bar.
- If a Tauri command is invoked which requires the Context to be available, an error will be returned
- As soon as the Context becomes available the `Guest` requests the history and Bitcoin balance
- Re-enables Material UI animations
This commit is contained in:
binarybaron 2024-09-03 12:28:30 +02:00 committed by GitHub
parent 792fbbf746
commit e4141c763b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 369 additions and 191 deletions

View file

@ -2,9 +2,8 @@ import { Box, makeStyles } from "@material-ui/core";
import FolderOpenIcon from "@material-ui/icons/FolderOpen";
import PlayArrowIcon from "@material-ui/icons/PlayArrow";
import StopIcon from "@material-ui/icons/Stop";
import { RpcProcessStateType } from "models/rpcModel";
import PromiseInvokeButton from "renderer/components/PromiseInvokeButton";
import { useAppSelector } from "store/hooks";
import { useIsContextAvailable } from "store/hooks";
import InfoBox from "../../modal/swap/InfoBox";
import CliLogsBox from "../../other/RenderedCliLog";
@ -17,20 +16,17 @@ const useStyles = makeStyles((theme) => ({
}));
export default function RpcControlBox() {
const rpcProcess = useAppSelector((state) => state.rpc.process);
const isRunning =
rpcProcess.type === RpcProcessStateType.STARTED ||
rpcProcess.type === RpcProcessStateType.LISTENING_FOR_CONNECTIONS;
const isRunning = useIsContextAvailable();
const classes = useStyles();
return (
<InfoBox
title={`Swap Daemon (${rpcProcess.type})`}
title={`Daemon Controller`}
mainContent={
isRunning || rpcProcess.type === RpcProcessStateType.EXITED ? (
isRunning ? (
<CliLogsBox
label="Swap Daemon Logs (current session only)"
logs={rpcProcess.logs}
logs={[]}
/>
) : null
}