forked from comit-network/xmr-btc-swap
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
792fbbf
commit e4141c7
Showing
17 changed files
with
369 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src-gui/src/renderer/components/alert/DaemonStatusAlert.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { CircularProgress } from "@material-ui/core"; | ||
import { Alert, AlertProps } from "@material-ui/lab"; | ||
import { TauriContextInitializationProgress } from "models/tauriModel"; | ||
import { useState } from "react"; | ||
import { useAppSelector } from "store/hooks"; | ||
import { exhaustiveGuard } from "utils/typescriptUtils"; | ||
|
||
const FUNNY_INIT_MESSAGES = [ | ||
"Initializing quantum entanglement...", | ||
"Generating one-time pads from cosmic background radiation...", | ||
"Negotiating key exchange with aliens...", | ||
"Optimizing elliptic curves for maximum sneakiness...", | ||
"Transforming plaintext into ciphertext via arcane XOR rituals...", | ||
"Salting your hash with exotic mathematical seasonings...", | ||
"Performing advanced modular arithmetic gymnastics...", | ||
"Consulting the Oracle of Randomness...", | ||
"Executing top-secret permutation protocols...", | ||
"Summoning prime factors from the mathematical aether...", | ||
"Deploying steganographic squirrels to hide your nuts of data...", | ||
"Initializing the quantum superposition of your keys...", | ||
"Applying post-quantum cryptographic voodoo...", | ||
"Encrypting your data with the tears of frustrated regulators...", | ||
]; | ||
|
||
function LoadingSpinnerAlert({ ...rest }: AlertProps) { | ||
return <Alert icon={<CircularProgress size={22} />} {...rest} />; | ||
} | ||
|
||
export default function DaemonStatusAlert() { | ||
const contextStatus = useAppSelector((s) => s.rpc.status); | ||
|
||
const [initMessage] = useState( | ||
FUNNY_INIT_MESSAGES[Math.floor(Math.random() * FUNNY_INIT_MESSAGES.length)], | ||
); | ||
|
||
if (contextStatus == null) { | ||
return ( | ||
<LoadingSpinnerAlert severity="warning"> | ||
{initMessage} | ||
</LoadingSpinnerAlert> | ||
); | ||
} | ||
|
||
switch (contextStatus.type) { | ||
case "Initializing": | ||
switch (contextStatus.content) { | ||
case TauriContextInitializationProgress.OpeningBitcoinWallet: | ||
return ( | ||
<LoadingSpinnerAlert severity="warning"> | ||
Connecting to the Bitcoin network | ||
</LoadingSpinnerAlert> | ||
); | ||
case TauriContextInitializationProgress.OpeningMoneroWallet: | ||
return ( | ||
<LoadingSpinnerAlert severity="warning"> | ||
Connecting to the Monero network | ||
</LoadingSpinnerAlert> | ||
); | ||
case TauriContextInitializationProgress.OpeningDatabase: | ||
return ( | ||
<LoadingSpinnerAlert severity="warning"> | ||
Opening the local database | ||
</LoadingSpinnerAlert> | ||
); | ||
} | ||
break; | ||
case "Available": | ||
return <Alert severity="success">The daemon is running</Alert>; | ||
case "Failed": | ||
return ( | ||
<Alert severity="error">The daemon has stopped unexpectedly</Alert> | ||
); | ||
default: | ||
return exhaustiveGuard(contextStatus); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions
26
src-gui/src/renderer/components/pages/history/table/HistoryRowExpanded.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.