From b98c7a1e9f1c2fbeb1d268873a58b71c7fe59601 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 20 Feb 2023 07:19:17 -0800 Subject: [PATCH] Add TOR loading component --- frontend/src/App.tsx | 13 +- frontend/src/basic/Main.tsx | 4 +- frontend/src/basic/RobotPage/RobotProfile.tsx | 2 +- frontend/src/basic/RobotPage/index.tsx | 176 +++++--- frontend/src/basic/UserGenPage.js | 395 ++++++++++++++++++ frontend/src/components/TorConnection.tsx | 25 +- 6 files changed, 534 insertions(+), 81 deletions(-) create mode 100644 frontend/src/basic/UserGenPage.js diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 93974b34..0b15fa0c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,7 +4,7 @@ import Main from './basic/Main'; import { CssBaseline } from '@mui/material'; import { ThemeProvider, createTheme, Theme } from '@mui/material/styles'; import UnsafeAlert from './components/UnsafeAlert'; -import TorConnection from './components/TorConnection'; +import TorConnectionBadge from './components/TorConnection'; import { I18nextProvider } from 'react-i18next'; import i18n from './i18n/Web'; @@ -29,6 +29,13 @@ const makeTheme = function (settings: Settings) { const App = (): JSX.Element => { const [theme, setTheme] = useState(makeTheme(new Settings())); const [settings, setSettings] = useState(new Settings()); + const [torStatus, setTorStatus] = useState('NOTINIT'); + + useEffect(() => { + window.addEventListener('torStatus', (event) => { + setTorStatus(event?.detail); + }); + }, []); useEffect(() => { setTheme(makeTheme(settings)); @@ -46,9 +53,9 @@ const App = (): JSX.Element => { {window.NativeRobosats === undefined ? ( ) : ( - + )} -
+
diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index 010c346d..f29815e6 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -71,10 +71,11 @@ interface SlideDirection { interface MainProps { settings: Settings; + torStatus: 'NOTINIT' | 'STARTING' | '"Done"' | 'DONE'; setSettings: (state: Settings) => void; } -const Main = ({ settings, setSettings }: MainProps): JSX.Element => { +const Main = ({ torStatus, settings, setSettings }: MainProps): JSX.Element => { const { t } = useTranslation(); const theme = useTheme(); @@ -351,6 +352,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
+ ) : ( + +
+ +
+
+ )} + + + + +
+ +
+ + + + + {t('Simple and Private LN P2P Exchange')} + + + + + + +
+ + + ); + } +} + +export default withTranslation()(UserGenPage); diff --git a/frontend/src/components/TorConnection.tsx b/frontend/src/components/TorConnection.tsx index 57754e87..bf9888bb 100644 --- a/frontend/src/components/TorConnection.tsx +++ b/frontend/src/components/TorConnection.tsx @@ -2,16 +2,20 @@ import React, { useEffect, useState } from 'react'; import { Box, CircularProgress, Tooltip } from '@mui/material'; import { TorIcon } from './Icons'; import { useTranslation } from 'react-i18next'; -import { gridQuickFilterValuesSelector } from '@mui/x-data-grid'; -interface Props { +interface TorIndicatorProps { color: 'inherit' | 'error' | 'warning' | 'success' | 'primary' | 'secondary' | 'info' | undefined; tooltipOpen?: boolean | undefined; title: string; progress: boolean; } -const TorIndicator = ({ color, tooltipOpen = undefined, title, progress }: Props): JSX.Element => { +const TorIndicator = ({ + color, + tooltipOpen = undefined, + title, + progress, +}: TorIndicatorProps): JSX.Element => { return ( { - const [torStatus, setTorStatus] = useState('NOTINIT'); - const { t } = useTranslation(); +interface TorConnectionBadgeProps { + torStatus: 'NOTINIT' | 'STARTING' | '"Done"' | 'DONE'; +} - useEffect(() => { - window.addEventListener('torStatus', (event) => { - setTorStatus(event?.detail); - }); - }, []); +const TorConnectionBadge = ({ torStatus }: TorConnectionBadgeProps): JSX.Element => { + const { t } = useTranslation(); if (window?.NativeRobosats == null) { return <>; @@ -95,4 +96,4 @@ const TorConnection = (): JSX.Element => { } }; -export default TorConnection; +export default TorConnectionBadge;