Fix (some) lint issues

This commit is contained in:
Reckless_Satoshi 2023-10-27 04:00:53 -07:00 committed by Reckless_Satoshi
parent 66c16760f6
commit 2361b728fc
33 changed files with 113 additions and 86 deletions

View File

@ -12,8 +12,8 @@ import BookTable from '../../components/BookTable';
import { BarChart, FormatListBulleted, Map } from '@mui/icons-material'; import { BarChart, FormatListBulleted, Map } from '@mui/icons-material';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import MapChart from '../../components/Charts/MapChart'; import MapChart from '../../components/Charts/MapChart';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
const BookPage = (): JSX.Element => { const BookPage = (): JSX.Element => {
const { windowSize } = useContext<UseAppStoreType>(AppContext); const { windowSize } = useContext<UseAppStoreType>(AppContext);

View File

@ -8,8 +8,8 @@ import RobotAvatar from '../components/RobotAvatar';
import Notifications from '../components/Notifications'; import Notifications from '../components/Notifications';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FederationContext, UseFederationStoreType } from '../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../contexts/GarageContext';
const Router = window.NativeRobosats === undefined ? BrowserRouter : MemoryRouter; const Router = window.NativeRobosats === undefined ? BrowserRouter : MemoryRouter;
@ -46,7 +46,9 @@ const Main: React.FC = () => {
style={{ display: 'none' }} style={{ display: 'none' }}
nickname={garage.getRobot().nickname} nickname={garage.getRobot().nickname}
baseUrl={federation.getCoordinator(sortedCoordinators[0]).getBaseUrl()} baseUrl={federation.getCoordinator(sortedCoordinators[0]).getBaseUrl()}
onLoad={() => garage.updateRobot({ avatarLoaded: true })} onLoad={() => {
garage.updateRobot({ avatarLoaded: true });
}}
/> />
<Notifications <Notifications
page={page} page={page}

View File

@ -11,7 +11,7 @@ import {
} from '../../components/Dialogs'; } from '../../components/Dialogs';
import { pn } from '../../utils'; import { pn } from '../../utils';
import { AppContext, type UseAppStoreType, closeAll } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType, closeAll } from '../../contexts/AppContext';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
export interface OpenDialogs { export interface OpenDialogs {
more: boolean; more: boolean;

View File

@ -9,8 +9,8 @@ import BookTable from '../../components/BookTable';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { NoRobotDialog } from '../../components/Dialogs'; import { NoRobotDialog } from '../../components/Dialogs';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
const MakerPage = (): JSX.Element => { const MakerPage = (): JSX.Element => {
const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext); const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);

View File

@ -16,8 +16,8 @@ import {
} from '@mui/icons-material'; } from '@mui/icons-material';
import RobotAvatar from '../../components/RobotAvatar'; import RobotAvatar from '../../components/RobotAvatar';
import { AppContext, type UseAppStoreType, closeAll } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType, closeAll } from '../../contexts/AppContext';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
const NavBar = (): JSX.Element => { const NavBar = (): JSX.Element => {
const theme = useTheme(); const theme = useTheme();
@ -79,7 +79,6 @@ const NavBar = (): JSX.Element => {
const changePage = function (mouseEvent: any, newPage: Page): void { const changePage = function (mouseEvent: any, newPage: Page): void {
if (newPage === 'none') { if (newPage === 'none') {
return;
} else { } else {
handleSlideDirection(page, newPage); handleSlideDirection(page, newPage);
setPage(newPage); setPage(newPage);

View File

@ -8,8 +8,8 @@ import OrderDetails from '../../components/OrderDetails';
import { apiClient } from '../../services/api'; import { apiClient } from '../../services/api';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
const OrderPage = (): JSX.Element => { const OrderPage = (): JSX.Element => {
const { windowSize, setOpen, settings, navbarHeight, hostUrl, origin } = const { windowSize, setOpen, settings, navbarHeight, hostUrl, origin } =

View File

@ -21,8 +21,8 @@ import RobotAvatar from '../../components/RobotAvatar';
import TokenInput from './TokenInput'; import TokenInput from './TokenInput';
import { genBase62Token } from '../../utils'; import { genBase62Token } from '../../utils';
import { NewTabIcon } from '../../components/Icons'; import { NewTabIcon } from '../../components/Icons';
import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
interface OnboardingProps { interface OnboardingProps {
setView: (state: 'welcome' | 'onboarding' | 'recovery' | 'profile') => void; setView: (state: 'welcome' | 'onboarding' | 'recovery' | 'profile') => void;

View File

@ -21,8 +21,8 @@ import { type Slot, type Robot } from '../../models';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { genBase62Token } from '../../utils'; import { genBase62Token } from '../../utils';
import { LoadingButton } from '@mui/lab'; import { LoadingButton } from '@mui/lab';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
interface RobotProfileProps { interface RobotProfileProps {
robot: Robot; robot: Robot;

View File

@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import { IconButton, LinearProgress, TextField, Tooltip } from '@mui/material'; import { IconButton, LinearProgress, TextField, Tooltip } from '@mui/material';
import { ContentCopy } from '@mui/icons-material'; import { ContentCopy } from '@mui/icons-material';
import { systemClient } from '../../services/System'; import { systemClient } from '../../services/System';
import { UseGarageStoreType, GarageContext } from '../../contexts/GarageContext'; import { type UseGarageStoreType, GarageContext } from '../../contexts/GarageContext';
interface TokenInputProps { interface TokenInputProps {
editable?: boolean; editable?: boolean;

View File

@ -21,8 +21,8 @@ import { TorIcon } from '../../components/Icons';
import { genKey } from '../../pgp'; import { genKey } from '../../pgp';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { validateTokenEntropy } from '../../utils'; import { validateTokenEntropy } from '../../utils';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
interface RobotPageProps { interface RobotPageProps {
avatarBaseUrl: string; avatarBaseUrl: string;

View File

@ -37,7 +37,7 @@ import RobotAvatar from '../RobotAvatar';
// Icons // Icons
import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material'; import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
const ClickThroughDataGrid = styled(DataGrid)({ const ClickThroughDataGrid = styled(DataGrid)({
'& .MuiDataGrid-overlayWrapperInner': { '& .MuiDataGrid-overlayWrapperInner': {
@ -831,7 +831,11 @@ const BookTable = ({
</IconButton> </IconButton>
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
<IconButton onClick={() => federation.update()}> <IconButton
onClick={() => {
federation.update();
}}
>
<Refresh /> <Refresh />
</IconButton> </IconButton>
</Grid> </Grid>

View File

@ -26,7 +26,10 @@ import currencyDict from '../../../../static/assets/currencies.json';
import getNivoScheme from '../NivoScheme'; import getNivoScheme from '../NivoScheme';
import OrderTooltip from '../helpers/OrderTooltip'; import OrderTooltip from '../helpers/OrderTooltip';
import { type UseAppStoreType, AppContext } from '../../../contexts/AppContext'; import { type UseAppStoreType, AppContext } from '../../../contexts/AppContext';
import { FederationContext, UseFederationStoreType } from '../../../contexts/FederationContext'; import {
FederationContext,
type UseFederationStoreType,
} from '../../../contexts/FederationContext';
interface DepthChartProps { interface DepthChartProps {
maxWidth: number; maxWidth: number;

View File

@ -15,7 +15,10 @@ import Map from '../../Map';
import { AppContext, type UseAppStoreType } from '../../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../../contexts/AppContext';
import { PhotoSizeSelectActual } from '@mui/icons-material'; import { PhotoSizeSelectActual } from '@mui/icons-material';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FederationContext, UseFederationStoreType } from '../../../contexts/FederationContext'; import {
FederationContext,
type UseFederationStoreType,
} from '../../../contexts/FederationContext';
interface MapChartProps { interface MapChartProps {
maxWidth: number; maxWidth: number;

View File

@ -7,7 +7,10 @@ import currencyDict from '../../../../../static/assets/currencies.json';
import { PaymentStringAsIcons } from '../../../PaymentMethods'; import { PaymentStringAsIcons } from '../../../PaymentMethods';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { AppContext, type UseAppStoreType } from '../../../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../../../contexts/AppContext';
import { FederationContext, UseFederationStoreType } from '../../../../contexts/FederationContext'; import {
FederationContext,
type UseFederationStoreType,
} from '../../../../contexts/FederationContext';
interface OrderTooltipProps { interface OrderTooltipProps {
order: PublicOrder; order: PublicOrder;

View File

@ -16,9 +16,9 @@ import {
import BoltIcon from '@mui/icons-material/Bolt'; import BoltIcon from '@mui/icons-material/Bolt';
import RobotAvatar from '../RobotAvatar'; import RobotAvatar from '../RobotAvatar';
import RobotInfo from '../RobotInfo'; import RobotInfo from '../RobotInfo';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
import { Coordinator } from '../../models'; import { type Coordinator } from '../../models';
interface Props { interface Props {
open: boolean; open: boolean;
@ -97,7 +97,7 @@ const ProfileDialog = ({ open = false, baseUrl, onClose }: Props): JSX.Element =
</Typography> </Typography>
{Object.values(federation.coordinators).map((coordinator: Coordinator): JSX.Element => { {Object.values(federation.coordinators).map((coordinator: Coordinator): JSX.Element => {
if (garage.getRobot()?.loading === false) { if (!garage.getRobot()?.loading) {
return ( return (
<div key={coordinator.shortAlias}> <div key={coordinator.shortAlias}>
<RobotInfo <RobotInfo

View File

@ -5,10 +5,10 @@ import { DataGrid, type GridColDef, type GridValidRowModel } from '@mui/x-data-g
import { type Coordinator } from '../../models'; import { type Coordinator } from '../../models';
import RobotAvatar from '../RobotAvatar'; import RobotAvatar from '../RobotAvatar';
import { Link, LinkOff } from '@mui/icons-material'; import { Link, LinkOff } from '@mui/icons-material';
import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { import {
ActionFederation, type ActionFederation,
UseFederationStoreType, type UseFederationStoreType,
FederationContext, FederationContext,
} from '../../contexts/FederationContext'; } from '../../contexts/FederationContext';

View File

@ -43,8 +43,8 @@ import { LoadingButton } from '@mui/lab';
import { fiatMethods } from '../PaymentMethods'; import { fiatMethods } from '../PaymentMethods';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import SelectCoordinator from './SelectCoordinator'; import SelectCoordinator from './SelectCoordinator';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
interface MakerFormProps { interface MakerFormProps {
disableRequest?: boolean; disableRequest?: boolean;

View File

@ -13,7 +13,7 @@ import RobotAvatar from '../RobotAvatar';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
interface SelectCoordinatorProps { interface SelectCoordinatorProps {
coordinator: string; coordinator: string;

View File

@ -8,7 +8,7 @@ import { type PublicOrder } from '../../models';
import OrderTooltip from '../Charts/helpers/OrderTooltip'; import OrderTooltip from '../Charts/helpers/OrderTooltip';
import getWorldmapGeojson from '../../geo/Web'; import getWorldmapGeojson from '../../geo/Web';
import MarkerClusterGroup from '@christopherpickering/react-leaflet-markercluster'; import MarkerClusterGroup from '@christopherpickering/react-leaflet-markercluster';
import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
interface MapPinProps { interface MapPinProps {
fillColor: string; fillColor: string;

View File

@ -11,7 +11,7 @@ import {
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import Close from '@mui/icons-material/Close'; import Close from '@mui/icons-material/Close';
import { type Page } from '../../basic/NavBar'; import { type Page } from '../../basic/NavBar';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
interface NotificationsProps { interface NotificationsProps {
rewards: number | undefined; rewards: number | undefined;

View File

@ -25,9 +25,9 @@ import { type Order, type Info } from '../../models';
import { ConfirmationDialog } from '../Dialogs'; import { ConfirmationDialog } from '../Dialogs';
import { LoadingButton } from '@mui/lab'; import { LoadingButton } from '@mui/lab';
import { computeSats } from '../../utils'; import { computeSats } from '../../utils';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
import { UseAppStoreType, AppContext } from '../../contexts/AppContext'; import { type UseAppStoreType, AppContext } from '../../contexts/AppContext';
import { UseFederationStoreType, FederationContext } from '../../contexts/FederationContext'; import { type UseFederationStoreType, FederationContext } from '../../contexts/FederationContext';
interface TakeButtonProps { interface TakeButtonProps {
baseUrl: string; baseUrl: string;

View File

@ -40,9 +40,9 @@ import type { Order, Coordinator } from '../../models';
import { statusBadgeColor, pn, amountToString, computeSats } from '../../utils'; import { statusBadgeColor, pn, amountToString, computeSats } from '../../utils';
import TakeButton from './TakeButton'; import TakeButton from './TakeButton';
import { F2fMapDialog } from '../Dialogs'; import { F2fMapDialog } from '../Dialogs';
import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
import { UseFederationStoreType, FederationContext } from '../../contexts/FederationContext'; import { type UseFederationStoreType, FederationContext } from '../../contexts/FederationContext';
interface OrderDetailsProps { interface OrderDetailsProps {
coordinator: Coordinator; coordinator: Coordinator;

View File

@ -4,8 +4,8 @@ import { Avatar, Badge, Tooltip } from '@mui/material';
import { SendReceiveIcon } from '../Icons'; import { SendReceiveIcon } from '../Icons';
import { apiClient } from '../../services/api'; import { apiClient } from '../../services/api';
import placeholder from './placeholder.json'; import placeholder from './placeholder.json';
import { UseAppStoreType, AppContext } from '../../contexts/AppContext'; import { type UseAppStoreType, AppContext } from '../../contexts/AppContext';
import { UseFederationStoreType, FederationContext } from '../../contexts/FederationContext'; import { type UseFederationStoreType, FederationContext } from '../../contexts/FederationContext';
interface Props { interface Props {
nickname: string | undefined; nickname: string | undefined;

View File

@ -50,9 +50,9 @@ import { type EncryptedChatMessage } from './EncryptedChat';
import CollabCancelAlert from './CollabCancelAlert'; import CollabCancelAlert from './CollabCancelAlert';
import { Bolt } from '@mui/icons-material'; import { Bolt } from '@mui/icons-material';
import { signCleartextMessage } from '../../pgp'; import { signCleartextMessage } from '../../pgp';
import { UseFederationStoreType, FederationContext } from '../../contexts/FederationContext'; import { type UseFederationStoreType, FederationContext } from '../../contexts/FederationContext';
import { UseGarageStoreType, GarageContext } from '../../contexts/GarageContext'; import { type UseGarageStoreType, GarageContext } from '../../contexts/GarageContext';
import { UseAppStoreType, AppContext } from '../../contexts/AppContext'; import { type UseAppStoreType, AppContext } from '../../contexts/AppContext';
interface loadingButtonsProps { interface loadingButtonsProps {
cancel: boolean; cancel: boolean;
@ -287,7 +287,6 @@ const TradeBox = ({
}); });
// If Webln implements locked payments compatibility, this logic might be simplier // If Webln implements locked payments compatibility, this logic might be simplier
if (webln === undefined) { if (webln === undefined) {
return;
} else if (order.is_maker && order.status === 0) { } else if (order.is_maker && order.status === 0) {
webln.sendPayment(order.bond_invoice); webln.sendPayment(order.bond_invoice);
setWaitingWebln(true); setWaitingWebln(true);
@ -696,7 +695,7 @@ const TradeBox = ({
return { title, titleVariables, titleColor, prompt, bondStatus, titleIcon }; return { title, titleVariables, titleColor, prompt, bondStatus, titleIcon };
}; };
const contract = currentOrder.order ? statusToContract(currentOrder.order) : null; const contract = currentOrder.order != null ? statusToContract(currentOrder.order) : null;
return ( return (
<Box> <Box>

View File

@ -2,7 +2,7 @@ import { createContext, type Dispatch, useEffect, useState, type SetStateAction
import { type Page } from '../basic/NavBar'; import { type Page } from '../basic/NavBar';
import { type OpenDialogs } from '../basic/MainDialogs'; import { type OpenDialogs } from '../basic/MainDialogs';
import { Settings, type Version, type Origin, Favorites } from '../models'; import { Settings, type Version, type Origin, type Favorites } from '../models';
import { getClientVersion, getHost } from '../utils'; import { getClientVersion, getHost } from '../utils';
@ -25,10 +25,13 @@ export interface SlideDirection {
export type TorStatus = 'NOTINIT' | 'STARTING' | '"Done"' | 'DONE'; export type TorStatus = 'NOTINIT' | 'STARTING' | '"Done"' | 'DONE';
const entryPage: Page = export const isNativeRoboSats = !(window.NativeRobosats === undefined);
window.NativeRobosats === undefined
? ((window.location.pathname.split('/')[1] ?? 'robot') as Page) const pageFromPath = window.location.pathname.split('/')[1];
: 'robot'; const isPagePathEmpty = pageFromPath === '';
const entryPage: Page = !isNativeRoboSats
? ((isPagePathEmpty ? 'robot' : pageFromPath) as Page)
: 'robot';
export const closeAll = { export const closeAll = {
more: false, more: false,
@ -73,7 +76,7 @@ const getHostUrl = (network = 'mainnet'): string => {
}; };
const getOrigin = (network = 'mainnet'): Origin => { const getOrigin = (network = 'mainnet'): Origin => {
let host = getHostUrl(network); const host = getHostUrl(network);
let origin: Origin = 'onion'; let origin: Origin = 'onion';
if (window.NativeRobosats !== undefined || host.includes('.onion')) { if (window.NativeRobosats !== undefined || host.includes('.onion')) {

View File

@ -8,12 +8,12 @@ import {
useContext, useContext,
} from 'react'; } from 'react';
import { Coordinator, type Order, Federation } from '../models'; import { type Coordinator, type Order, Federation } from '../models';
import { federationLottery } from '../utils'; import { federationLottery } from '../utils';
import { AppContext, UseAppStoreType } from './AppContext'; import { AppContext, type UseAppStoreType } from './AppContext';
import { GarageContext, UseGarageStoreType } from './GarageContext'; import { GarageContext, type UseGarageStoreType } from './GarageContext';
// Refresh delays (ms) according to Order status // Refresh delays (ms) according to Order status
const statusToDelay = [ const statusToDelay = [

View File

@ -1,5 +1,12 @@
import { sha256 } from 'js-sha256'; import { sha256 } from 'js-sha256';
import { type Robot, type LimitList, type PublicOrder, Settings, Order, Garage } from '.'; import {
type Robot,
type LimitList,
type PublicOrder,
type Settings,
type Order,
type Garage,
} from '.';
import { apiClient } from '../services/api'; import { apiClient } from '../services/api';
import { hexToBase91, validateTokenEntropy } from '../utils'; import { hexToBase91, validateTokenEntropy } from '../utils';
import { compareUpdateLimit } from './Limit.model'; import { compareUpdateLimit } from './Limit.model';
@ -182,7 +189,7 @@ export class Coordinator {
apiClient apiClient
.get(this.url, `${this.basePath}/api/limits/`) .get(this.url, `${this.basePath}/api/limits/`)
.then((data) => { .then((data) => {
if (data) { if (data != null) {
const newLimits = data as LimitList; const newLimits = data as LimitList;
for (const currency in this.limits) { for (const currency in this.limits) {
@ -232,7 +239,7 @@ export class Coordinator {
}; };
isUpdated = () => { isUpdated = () => {
return ((this.loadingBook === this.loadingInfo) === this.loadingLimits) === false; return !((this.loadingBook === this.loadingInfo) === this.loadingLimits);
}; };
getBaseUrl = () => { getBaseUrl = () => {

View File

@ -1,15 +1,15 @@
import { import {
Coordinator, Coordinator,
Exchange, type Exchange,
Garage, type Garage,
Origin, type Origin,
PublicOrder, type PublicOrder,
Robot, type Robot,
Settings, type Settings,
defaultExchange, defaultExchange,
} from '.'; } from '.';
import defaultFederation from '../../static/federation.json'; import defaultFederation from '../../static/federation.json';
import { CurrentOrder } from '../contexts/FederationContext'; import { type CurrentOrder } from '../contexts/FederationContext';
import { updateExchangeInfo } from './Exchange.model'; import { updateExchangeInfo } from './Exchange.model';
type FederationHooks = 'onCoordinatorUpdate' | 'onFederationReady'; type FederationHooks = 'onCoordinatorUpdate' | 'onFederationReady';
@ -40,7 +40,7 @@ export class Federation {
public book: PublicOrder[]; public book: PublicOrder[];
public loading: boolean; public loading: boolean;
public hooks: Record<FederationHooks, (() => void)[]>; public hooks: Record<FederationHooks, Array<() => void>>;
// Hooks // Hooks
registerHook = (hookName: FederationHooks, fn: () => void): void => { registerHook = (hookName: FederationHooks, fn: () => void): void => {
@ -48,7 +48,9 @@ export class Federation {
}; };
triggerHook = (hookName: FederationHooks): void => { triggerHook = (hookName: FederationHooks): void => {
this.hooks[hookName]?.forEach((fn) => fn()); this.hooks[hookName]?.forEach((fn) => {
fn();
});
}; };
onCoordinatorSaved = (shortAlias: string) => { onCoordinatorSaved = (shortAlias: string) => {
@ -68,18 +70,18 @@ export class Federation {
this.onCoordinatorSaved(shortAlias); this.onCoordinatorSaved(shortAlias);
}; };
this.loading = true; this.loading = true;
Object.values(this.coordinators).forEach((coor) => Object.values(this.coordinators).forEach(async (coor) => {
coor.start(origin, settings, hostUrl, onCoordinatorStarted), await coor.start(origin, settings, hostUrl, onCoordinatorStarted);
); });
}; };
update = (): void => { update = (): void => {
this.loading = false; this.loading = false;
Object.values(this.coordinators).forEach((coor) => Object.values(this.coordinators).forEach(async (coor) => {
coor.update(() => { await coor.update(() => {
this.onCoordinatorSaved(coor.shortAlias); this.onCoordinatorSaved(coor.shortAlias);
}), });
); });
}; };
updateExchange = () => { updateExchange = () => {
@ -108,7 +110,7 @@ export class Federation {
return currentOrder; return currentOrder;
}; };
//Coordinators // Coordinators
getCoordinator = (shortAlias: string): Coordinator => { getCoordinator = (shortAlias: string): Coordinator => {
return this.coordinators[shortAlias]; return this.coordinators[shortAlias];
}; };

View File

@ -39,7 +39,7 @@ class Garage {
slots: Slot[]; slots: Slot[];
currentSlot: number; currentSlot: number;
hooks: Record<GarageHooks, (() => void)[]>; hooks: Record<GarageHooks, Array<() => void>>;
// Hooks // Hooks
registerHook = (hookName: GarageHooks, fn: () => void): void => { registerHook = (hookName: GarageHooks, fn: () => void): void => {
@ -47,7 +47,9 @@ class Garage {
}; };
triggerHook = (hookName: GarageHooks): void => { triggerHook = (hookName: GarageHooks): void => {
this.hooks[hookName]?.forEach((fn) => fn()); this.hooks[hookName]?.forEach((fn) => {
fn();
});
}; };
// Storage // Storage

View File

@ -3,7 +3,7 @@ import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { Paper } from '@mui/material'; import { Paper } from '@mui/material';
import BookTable from '../../components/BookTable'; import BookTable from '../../components/BookTable';
import { type GridItem } from 'react-grid-layout'; import { type GridItem } from 'react-grid-layout';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
interface BookWidgetProps { interface BookWidgetProps {
layout: GridItem; layout: GridItem;

View File

@ -2,7 +2,7 @@ import React, { useContext } from 'react';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { Paper } from '@mui/material'; import { Paper } from '@mui/material';
import DepthChart from '../../components/Charts/DepthChart'; import DepthChart from '../../components/Charts/DepthChart';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
interface DepthChartWidgetProps { interface DepthChartWidgetProps {
layout: any; layout: any;

View File

@ -3,8 +3,8 @@ import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import MakerForm from '../../components/MakerForm'; import MakerForm from '../../components/MakerForm';
import { Paper } from '@mui/material'; import { Paper } from '@mui/material';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
interface MakerWidgetProps { interface MakerWidgetProps {
style?: React.StyleHTMLAttributes<HTMLElement>; style?: React.StyleHTMLAttributes<HTMLElement>;

View File

@ -11,7 +11,7 @@
// donate to the development fund. This is the only way envisioned to incentivize // donate to the development fund. This is the only way envisioned to incentivize
// donations to the development fund. // donations to the development fund.
import { Federation } from '../models'; import { type Federation } from '../models';
export default function federationLottery(federation: Federation): string[] { export default function federationLottery(federation: Federation): string[] {
// Create an array to store the coordinator short aliases and their corresponding weights (chance) // Create an array to store the coordinator short aliases and their corresponding weights (chance)