From cc63b4d57ec5515855513562cb82336f6dce53a5 Mon Sep 17 00:00:00 2001 From: koalasat Date: Fri, 6 Sep 2024 10:41:15 +0200 Subject: [PATCH] Rebase --- frontend/src/App.tsx | 6 +- frontend/src/basic/Main.tsx | 92 ++----------------- frontend/src/basic/Routes.tsx | 8 +- .../src/components/OrderDetails/index.tsx | 4 +- .../EncryptedTurtleChat/index.tsx | 2 +- frontend/src/contexts/AppContext.tsx | 15 +-- frontend/src/models/Garage.model.ts | 2 +- frontend/src/services/Native/index.ts | 1 - frontend/static/locales/ca.json | 4 +- 9 files changed, 25 insertions(+), 109 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1bc158d1..90cee64b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -24,7 +24,11 @@ const App = (): JSX.Element => { - {(window.NativeRobosats === undefined && window.RobosatsClient === undefined )? : } + {window.NativeRobosats === undefined && window.RobosatsClient === undefined ? ( + + ) : ( + + )}
diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index 57483937..d78533d3 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; -import { MemoryRouter,HashRouter ,BrowserRouter, Routes, Route } from 'react-router-dom'; -import { Box, Slide, Typography, styled } from '@mui/material'; +import { MemoryRouter, HashRouter, BrowserRouter } from 'react-router-dom'; +import { Box, Typography, styled } from '@mui/material'; import { type UseAppStoreType, AppContext, closeAll } from '../contexts/AppContext'; import { NavBar, MainDialogs } from './'; @@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next'; import { GarageContext, type UseGarageStoreType } from '../contexts/GarageContext'; import Routes from './Routes'; -function getRouter() { +const getRouter = (): any => { if (window.NativeRobosats === undefined && window.RobosatsClient === undefined) { return BrowserRouter; } else if (window.RobosatsClient === 'desktop-app') { @@ -19,7 +19,7 @@ function getRouter() { } else { return MemoryRouter; } -} +}; const Router = getRouter(); const TestnetTypography = styled(Typography)({ @@ -39,7 +39,7 @@ const MainBox = styled(Box)((props) => ({ const Main: React.FC = () => { const { t } = useTranslation(); - const { settings, page, slideDirection, setOpen, windowSize, navbarHeight } = + const { settings, page, setOpen, windowSize, navbarHeight } = useContext(AppContext); const { garage } = useContext(GarageContext); @@ -63,87 +63,7 @@ const Main: React.FC = () => { )} - - {['/robot/:token?', '/', ''].map((path, index) => { - return ( - -
- -
- - } - key={index} - /> - ); - })} - - -
- -
- - } - /> - - -
- -
- - } - /> - - -
- -
- - } - /> - - -
- -
- - } - /> -
+
diff --git a/frontend/src/basic/Routes.tsx b/frontend/src/basic/Routes.tsx index 93797b81..909a7e45 100644 --- a/frontend/src/basic/Routes.tsx +++ b/frontend/src/basic/Routes.tsx @@ -1,10 +1,10 @@ import React, { useContext, useEffect } from 'react'; import { Routes as DomRoutes, Route, useNavigate } from 'react-router-dom'; -import { Box, Slide, Typography, styled } from '@mui/material'; +import { Slide } from '@mui/material'; import { type UseAppStoreType, AppContext } from '../contexts/AppContext'; import { RobotPage, MakerPage, BookPage, OrderPage, SettingsPage } from '.'; -import { GarageContext, UseGarageStoreType } from '../contexts/GarageContext'; +import { GarageContext, type UseGarageStoreType } from '../contexts/GarageContext'; const Routes: React.FC = () => { const navigate = useNavigate(); @@ -14,8 +14,8 @@ const Routes: React.FC = () => { useEffect(() => { window.addEventListener('navigateToPage', (event) => { console.log('navigateToPage', JSON.stringify(event)); - const orderId = event?.detail?.order_id; - const coordinator = event?.detail?.coordinator; + const orderId: string = event?.detail?.order_id; + const coordinator: string = event?.detail?.coordinator; if (orderId && coordinator) { const slot = garage.getSlotByOrder(coordinator, orderId); if (slot?.token) { diff --git a/frontend/src/components/OrderDetails/index.tsx b/frontend/src/components/OrderDetails/index.tsx index a368df36..1f4437ec 100644 --- a/frontend/src/components/OrderDetails/index.tsx +++ b/frontend/src/components/OrderDetails/index.tsx @@ -174,8 +174,8 @@ const OrderDetails = ({ const isBuyer = (order.type === 0 && order.is_maker) || (order.type === 1 && !order.is_maker); const tradeFee = order.is_maker - ? (coordinator.info?.maker_fee ?? 0) - : (coordinator.info?.taker_fee ?? 0); + ? coordinator.info?.maker_fee ?? 0 + : coordinator.info?.taker_fee ?? 0; const defaultRoutingBudget = 0.001; const btc_now = order.satoshis_now / 100000000; const rate = Number(order.max_amount ?? order.amount) / btc_now; diff --git a/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx index bccc035e..43de3a8f 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx @@ -39,7 +39,7 @@ const audioPath = window.NativeRobosats === undefined ? '/static/assets/sounds' : 'file:///android_asset/Web.bundle/assets/sounds'; - + const EncryptedTurtleChat: React.FC = ({ order, userNick, diff --git a/frontend/src/contexts/AppContext.tsx b/frontend/src/contexts/AppContext.tsx index bd543bf9..26bc3c36 100644 --- a/frontend/src/contexts/AppContext.tsx +++ b/frontend/src/contexts/AppContext.tsx @@ -76,20 +76,13 @@ const makeTheme = function (settings: Settings): Theme { }; const getHostUrl = (network = 'mainnet'): string => { - let host = ''; - let protocol = ''; - if(isDesktopRoboSats){ - host = defaultFederation.exp[network].onion; - protocol = 'http:'; - } - else if (window.NativeRobosats === undefined) { + let host = defaultFederation.exp[network].onion; + let protocol = 'http:'; + if (window.NativeRobosats === undefined) { host = getHost(); protocol = location.protocol; - } else { - host = defaultFederation.exp[network].onion; - protocol = 'http:'; } - const hostUrl = `${host}`; + const hostUrl = `${protocol}//${host}`; return hostUrl; }; diff --git a/frontend/src/models/Garage.model.ts b/frontend/src/models/Garage.model.ts index ec0b4379..07645be9 100644 --- a/frontend/src/models/Garage.model.ts +++ b/frontend/src/models/Garage.model.ts @@ -83,7 +83,7 @@ class Garage { // Slots getSlot: (token?: string) => Slot | null = (token) => { const currentToken = token ?? this.currentSlot; - return currentToken ? (this.slots[currentToken] ?? null) : null; + return currentToken ? this.slots[currentToken] ?? null : null; }; deleteSlot: (token?: string) => void = (token) => { diff --git a/frontend/src/services/Native/index.ts b/frontend/src/services/Native/index.ts index 77e9f5d8..5e8941a1 100644 --- a/frontend/src/services/Native/index.ts +++ b/frontend/src/services/Native/index.ts @@ -1,4 +1,3 @@ -import { redirect } from 'react-router-dom'; import { type NativeRobosatsPromise, type NativeWebViewMessage, diff --git a/frontend/static/locales/ca.json b/frontend/static/locales/ca.json index f9a394f6..50c080c7 100644 --- a/frontend/static/locales/ca.json +++ b/frontend/static/locales/ca.json @@ -250,7 +250,7 @@ "Tell us about a new feature or a bug": "Proposa funcionalitats o notifica errors", "We are abandoning Telegram! Our old TG groups": "Estem deixant Telegram! Els nostres grups antics de TG", "X Official Account": "Compte oficial a X", - "#23": "Phrases in components/Dialogs/Coordinator.tsx", + "#24": "Phrases in components/Dialogs/Coordinator.tsx", "...Opening on Nostr gateway. Pubkey copied!": "...Obrint la passarel·la Nostr. Clau pública copiada!", "24h contracted volume": "Volum contractat en 24h", "24h non-KYC bitcoin premium": "Prima de bitcoin sense KYC en 24h", @@ -475,7 +475,7 @@ "You send via Lightning {{amount}} Sats (Approx)": "Tu envies via Lightning {{amount}} Sats (Approx)", "You send via {{method}} {{amount}}": "Envies via {{method}} {{amount}}", "{{price}} {{currencyCode}}/BTC - Premium: {{premium}}%": "{{price}} {{currencyCode}}/BTC - Prima: {{premium}}%", - "#42": "Phrases in components/RobotInfo/index.tsx", + "#43": "Phrases in components/RobotInfo/index.tsx", "Active order!": "Active order!", "Claim": "Retirar", "Claim Sats!": "Reclamar Sats!",