This commit is contained in:
koalasat 2024-09-06 10:41:15 +02:00
parent 9a8a821b7b
commit cc63b4d57e
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157
9 changed files with 25 additions and 109 deletions

View File

@ -24,7 +24,11 @@ const App = (): JSX.Element => {
<GarageContextProvider>
<FederationContextProvider>
<CssBaseline />
{(window.NativeRobosats === undefined && window.RobosatsClient === undefined )? <HostAlert /> : <TorConnectionBadge />}
{window.NativeRobosats === undefined && window.RobosatsClient === undefined ? (
<HostAlert />
) : (
<TorConnectionBadge />
)}
<Main />
</FederationContextProvider>
</GarageContextProvider>

View File

@ -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)<MainBoxProps>((props) => ({
const Main: React.FC = () => {
const { t } = useTranslation();
const { settings, page, slideDirection, setOpen, windowSize, navbarHeight } =
const { settings, page, setOpen, windowSize, navbarHeight } =
useContext<UseAppStoreType>(AppContext);
const { garage } = useContext<UseGarageStoreType>(GarageContext);
@ -63,87 +63,7 @@ const Main: React.FC = () => {
)}
<MainBox navbarHeight={navbarHeight}>
<Routes>
{['/robot/:token?', '/', ''].map((path, index) => {
return (
<Route
path={path}
element={
<Slide
direction={page === 'robot' ? slideDirection.in : slideDirection.out}
in={page === 'robot'}
appear={slideDirection.in !== undefined}
>
<div>
<RobotPage />
</div>
</Slide>
}
key={index}
/>
);
})}
<Route
path={'/offers'}
element={
<Slide
direction={page === 'offers' ? slideDirection.in : slideDirection.out}
in={page === 'offers'}
appear={slideDirection.in !== undefined}
>
<div>
<BookPage />
</div>
</Slide>
}
/>
<Route
path='/create'
element={
<Slide
direction={page === 'create' ? slideDirection.in : slideDirection.out}
in={page === 'create'}
appear={slideDirection.in !== undefined}
>
<div>
<MakerPage />
</div>
</Slide>
}
/>
<Route
path='/order/:shortAlias/:orderId'
element={
<Slide
direction={page === 'order' ? slideDirection.in : slideDirection.out}
in={page === 'order'}
appear={slideDirection.in !== undefined}
>
<div>
<OrderPage />
</div>
</Slide>
}
/>
<Route
path='/settings'
element={
<Slide
direction={page === 'settings' ? slideDirection.in : slideDirection.out}
in={page === 'settings'}
appear={slideDirection.in !== undefined}
>
<div>
<SettingsPage />
</div>
</Slide>
}
/>
</Routes>
<Routes />
</MainBox>
<NavBar />
<MainDialogs />

View File

@ -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) {

View File

@ -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;

View File

@ -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;
};

View File

@ -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) => {

View File

@ -1,4 +1,3 @@
import { redirect } from 'react-router-dom';
import {
type NativeRobosatsPromise,
type NativeWebViewMessage,

View File

@ -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!",