mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Small fixes and lint fixes
This commit is contained in:
@ -31,7 +31,7 @@ const BookPage = (): JSX.Element => {
|
|||||||
const chartWidthEm = width - maxBookTableWidth;
|
const chartWidthEm = width - maxBookTableWidth;
|
||||||
|
|
||||||
const onOrderClicked = function (id: number, shortAlias: string): void {
|
const onOrderClicked = function (id: number, shortAlias: string): void {
|
||||||
if (Boolean(garage.getSlot()?.hashId)) {
|
if (garage.getSlot()?.hashId) {
|
||||||
setDelay(10000);
|
setDelay(10000);
|
||||||
navigate(`/order/${shortAlias}/${id}`);
|
navigate(`/order/${shortAlias}/${id}`);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -51,7 +51,7 @@ const MakerPage = (): JSX.Element => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const onOrderClicked = function (id: number): void {
|
const onOrderClicked = function (id: number): void {
|
||||||
if (Boolean(garage.getSlot()?.hashId)) {
|
if (garage.getSlot()?.hashId) {
|
||||||
navigate(`/order/${id}`);
|
navigate(`/order/${id}`);
|
||||||
} else {
|
} else {
|
||||||
setOpenNoRobot(true);
|
setOpenNoRobot(true);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const NavBar = (): JSX.Element => {
|
|||||||
const tabSx = smallBar
|
const tabSx = smallBar
|
||||||
? {
|
? {
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
bottom: Boolean(garage.getSlot()?.hashId) ? '0.9em' : '0.13em',
|
bottom: garage.getSlot()?.hashId ? '0.9em' : '0.13em',
|
||||||
minWidth: '1em',
|
minWidth: '1em',
|
||||||
}
|
}
|
||||||
: { position: 'relative', bottom: '1em', minWidth: '2em' };
|
: { position: 'relative', bottom: '1em', minWidth: '2em' };
|
||||||
@ -155,10 +155,7 @@ const NavBar = (): JSX.Element => {
|
|||||||
sx={tabSx}
|
sx={tabSx}
|
||||||
label={smallBar ? undefined : t('Order')}
|
label={smallBar ? undefined : t('Order')}
|
||||||
value='order'
|
value='order'
|
||||||
disabled={
|
disabled={!slot?.hashId || !slot?.getRobot(slot?.activeShortAlias ?? '')?.activeOrderId}
|
||||||
!Boolean(slot?.hashId) ||
|
|
||||||
!Boolean(slot?.getRobot(slot?.activeShortAlias ?? '')?.activeOrderId)
|
|
||||||
}
|
|
||||||
icon={<Assignment />}
|
icon={<Assignment />}
|
||||||
iconPosition='start'
|
iconPosition='start'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -59,7 +59,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
updateCurrentOrder();
|
updateCurrentOrder();
|
||||||
}, [currentOrderId]);
|
}, [currentOrderId]);
|
||||||
|
|
||||||
const updateCurrentOrder = () => {
|
const updateCurrentOrder = (): void => {
|
||||||
if (currentOrderId !== null) {
|
if (currentOrderId !== null) {
|
||||||
const coordinator = federation.getCoordinator(params.shortAlias ?? '');
|
const coordinator = federation.getCoordinator(params.shortAlias ?? '');
|
||||||
const slot = garage.getSlot();
|
const slot = garage.getSlot();
|
||||||
@ -71,7 +71,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
.then((order) => {
|
.then((order) => {
|
||||||
if (order?.bad_request !== undefined) {
|
if (order?.bad_request !== undefined) {
|
||||||
setBadOrder(order.bad_request);
|
setBadOrder(order.bad_request);
|
||||||
} else if (Boolean(order?.id)) {
|
} else if (order?.id) {
|
||||||
setCurrentOrder(order);
|
setCurrentOrder(order);
|
||||||
if (order?.is_participant) {
|
if (order?.is_participant) {
|
||||||
garage.updateOrder(order);
|
garage.updateOrder(order);
|
||||||
@ -122,7 +122,8 @@ const OrderPage = (): JSX.Element => {
|
|||||||
<WarningDialog
|
<WarningDialog
|
||||||
open={open.warning}
|
open={open.warning}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpen(closeAll), setAcknowledgedWarning(true);
|
setOpen(closeAll);
|
||||||
|
setAcknowledgedWarning(true);
|
||||||
}}
|
}}
|
||||||
longAlias={federation.getCoordinator(params.shortAlias ?? '').longAlias}
|
longAlias={federation.getCoordinator(params.shortAlias ?? '').longAlias}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -62,7 +62,6 @@ const Onboarding = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const slot = garage.getSlot();
|
const slot = garage.getSlot();
|
||||||
const robot = slot?.getRobot();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@ -151,7 +150,7 @@ const Onboarding = ({
|
|||||||
<Grid container direction='column' alignItems='center' spacing={1}>
|
<Grid container direction='column' alignItems='center' spacing={1}>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Typography>
|
<Typography>
|
||||||
{Boolean(slot?.hashId) ? (
|
{slot?.hashId ? (
|
||||||
t('This is your trading avatar')
|
t('This is your trading avatar')
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@ -179,7 +178,7 @@ const Onboarding = ({
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
{Boolean(slot?.hashId) ? (
|
{slot?.hashId ? (
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Typography align='center'>{t('Hi! My name is')}</Typography>
|
<Typography align='center'>{t('Hi! My name is')}</Typography>
|
||||||
<Typography component='h5' variant='h5'>
|
<Typography component='h5' variant='h5'>
|
||||||
@ -211,7 +210,7 @@ const Onboarding = ({
|
|||||||
</Grid>
|
</Grid>
|
||||||
) : null}
|
) : null}
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Collapse in={!!Boolean(slot?.hashId)}>
|
<Collapse in={!!slot?.hashId}>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setStep('3');
|
setStep('3');
|
||||||
|
|||||||
@ -22,7 +22,6 @@ 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, type UseGarageStoreType } from '../../contexts/GarageContext';
|
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
|
||||||
import { type UseFederationStoreType, FederationContext } from '../../contexts/FederationContext';
|
|
||||||
|
|
||||||
interface RobotProfileProps {
|
interface RobotProfileProps {
|
||||||
robot: Robot;
|
robot: Robot;
|
||||||
@ -46,7 +45,6 @@ const RobotProfile = ({
|
|||||||
}: RobotProfileProps): JSX.Element => {
|
}: RobotProfileProps): JSX.Element => {
|
||||||
const { windowSize } = useContext<UseAppStoreType>(AppContext);
|
const { windowSize } = useContext<UseAppStoreType>(AppContext);
|
||||||
const { garage, robotUpdatedAt, orderUpdatedAt } = useContext<UseGarageStoreType>(GarageContext);
|
const { garage, robotUpdatedAt, orderUpdatedAt } = useContext<UseGarageStoreType>(GarageContext);
|
||||||
const { sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
|
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -56,8 +54,7 @@ const RobotProfile = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const slot = garage.getSlot();
|
const slot = garage.getSlot();
|
||||||
const robot = slot?.getRobot(sortedCoordinators[0]);
|
if (slot?.hashId) {
|
||||||
if (Boolean(slot?.hashId)) {
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [orderUpdatedAt, robotUpdatedAt, loading]);
|
}, [orderUpdatedAt, robotUpdatedAt, loading]);
|
||||||
@ -87,7 +84,7 @@ const RobotProfile = ({
|
|||||||
sx={{ width: '100%' }}
|
sx={{ width: '100%' }}
|
||||||
>
|
>
|
||||||
<Grid item sx={{ height: '2.3em', position: 'relative' }}>
|
<Grid item sx={{ height: '2.3em', position: 'relative' }}>
|
||||||
{Boolean(slot?.hashId) ? (
|
{slot?.hashId ? (
|
||||||
<Typography align='center' component='h5' variant='h5'>
|
<Typography align='center' component='h5' variant='h5'>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@ -71,7 +71,7 @@ const TokenInput = ({
|
|||||||
<Tooltip open={showCopied} title={t('Copied!')}>
|
<Tooltip open={showCopied} title={t('Copied!')}>
|
||||||
<IconButton
|
<IconButton
|
||||||
autoFocus={autoFocusTarget === 'copyButton'}
|
autoFocus={autoFocusTarget === 'copyButton'}
|
||||||
color={Boolean(garage.getSlot()?.copiedToken) ? 'inherit' : 'primary'}
|
color={garage.getSlot()?.copiedToken ? 'inherit' : 'primary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
systemClient.copyToClipboard(inputToken);
|
systemClient.copyToClipboard(inputToken);
|
||||||
setShowCopied(true);
|
setShowCopied(true);
|
||||||
|
|||||||
@ -106,8 +106,7 @@ const BookTable = ({
|
|||||||
showNoResults = true,
|
showNoResults = true,
|
||||||
onOrderClicked = () => null,
|
onOrderClicked = () => null,
|
||||||
}: BookTableProps): JSX.Element => {
|
}: BookTableProps): JSX.Element => {
|
||||||
const { fav, setFav, settings, setOpen, hostUrl, origin } =
|
const { fav, setFav, setOpen } = useContext<UseAppStoreType>(AppContext);
|
||||||
useContext<UseAppStoreType>(AppContext);
|
|
||||||
const { federation, coordinatorUpdatedAt } =
|
const { federation, coordinatorUpdatedAt } =
|
||||||
useContext<UseFederationStoreType>(FederationContext);
|
useContext<UseFederationStoreType>(FederationContext);
|
||||||
|
|
||||||
@ -206,11 +205,6 @@ const BookTable = ({
|
|||||||
headerName: t('Robot'),
|
headerName: t('Robot'),
|
||||||
width: width * fontSize,
|
width: width * fontSize,
|
||||||
renderCell: (params: any) => {
|
renderCell: (params: any) => {
|
||||||
const { url, basePath } =
|
|
||||||
federation
|
|
||||||
.getCoordinator(params.row.coordinatorShortAlias)
|
|
||||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
style={{ cursor: 'pointer', position: 'relative', left: '-1.3em' }}
|
style={{ cursor: 'pointer', position: 'relative', left: '-1.3em' }}
|
||||||
@ -243,11 +237,6 @@ const BookTable = ({
|
|||||||
headerName: t('Robot'),
|
headerName: t('Robot'),
|
||||||
width: width * fontSize,
|
width: width * fontSize,
|
||||||
renderCell: (params: any) => {
|
renderCell: (params: any) => {
|
||||||
const { url, basePath } =
|
|
||||||
federation
|
|
||||||
.getCoordinator(params.row.coordinatorShortAlias)
|
|
||||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{ position: 'relative', left: '-0.34em', cursor: 'pointer' }}
|
style={{ position: 'relative', left: '-0.34em', cursor: 'pointer' }}
|
||||||
|
|||||||
@ -340,7 +340,7 @@ const BadgesHall = ({ badges }: BadgesProps): JSX.Element => {
|
|||||||
|
|
||||||
const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props): JSX.Element => {
|
const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { clientVersion, page, hostUrl } = useContext(AppContext);
|
const { clientVersion, page } = useContext(AppContext);
|
||||||
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
||||||
const coordinator = federation.getCoordinator(shortAlias);
|
const coordinator = federation.getCoordinator(shortAlias);
|
||||||
|
|
||||||
@ -480,11 +480,11 @@ const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props
|
|||||||
)}
|
)}
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
{Boolean(coordinator?.loadingInfo) ? (
|
{coordinator?.loadingInfo ? (
|
||||||
<Box style={{ display: 'flex', justifyContent: 'center' }}>
|
<Box style={{ display: 'flex', justifyContent: 'center' }}>
|
||||||
<CircularProgress />
|
<CircularProgress />
|
||||||
</Box>
|
</Box>
|
||||||
) : Boolean(coordinator?.info) ? (
|
) : coordinator?.info ? (
|
||||||
<Box>
|
<Box>
|
||||||
{Boolean(coordinator?.policies) && (
|
{Boolean(coordinator?.policies) && (
|
||||||
<Accordion
|
<Accordion
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const ProfileDialog = ({ open = false, baseUrl, onClose }: Props): JSX.Element =
|
|||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(!Boolean(garage.getSlot()?.hashId));
|
setLoading(!garage.getSlot()?.hashId);
|
||||||
}, [robotUpdatedAt]);
|
}, [robotUpdatedAt]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -96,7 +96,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 (Boolean(garage.getSlot()?.hashId)) {
|
if (garage.getSlot()?.hashId) {
|
||||||
return (
|
return (
|
||||||
<div key={coordinator.shortAlias}>
|
<div key={coordinator.shortAlias}>
|
||||||
<RobotInfo coordinator={coordinator} onClose={onClose} />
|
<RobotInfo coordinator={coordinator} onClose={onClose} />
|
||||||
|
|||||||
@ -93,7 +93,7 @@ const MakerForm = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const slot = garage.getSlot();
|
const slot = garage.getSlot();
|
||||||
if (Boolean(slot?.token)) void federation.fetchRobot(garage, slot?.token);
|
if (slot?.token) void federation.fetchRobot(garage, slot?.token);
|
||||||
}, [garage.currentSlot]);
|
}, [garage.currentSlot]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -104,7 +104,7 @@ const MakerForm = ({
|
|||||||
updateCoordinatorInfo();
|
updateCoordinatorInfo();
|
||||||
}, [maker.coordinator]);
|
}, [maker.coordinator]);
|
||||||
|
|
||||||
const updateCoordinatorInfo = () => {
|
const updateCoordinatorInfo = (): void => {
|
||||||
if (maker.coordinator != null) {
|
if (maker.coordinator != null) {
|
||||||
const newLimits = federation.getCoordinator(maker.coordinator).limits;
|
const newLimits = federation.getCoordinator(maker.coordinator).limits;
|
||||||
if (Object.keys(newLimits).length !== 0) {
|
if (Object.keys(newLimits).length !== 0) {
|
||||||
@ -294,7 +294,7 @@ const MakerForm = ({
|
|||||||
const handleCreateOrder = function (): void {
|
const handleCreateOrder = function (): void {
|
||||||
const slot = garage.getSlot();
|
const slot = garage.getSlot();
|
||||||
|
|
||||||
if (Boolean(slot?.activeShortAlias)) {
|
if (slot?.activeShortAlias) {
|
||||||
setBadRequest(t('You are already maker of an active order'));
|
setBadRequest(t('You are already maker of an active order'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ interface SelectCoordinatorProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SelectCoordinator: React.FC<SelectCoordinatorProps> = ({ coordinator, setCoordinator }) => {
|
const SelectCoordinator: React.FC<SelectCoordinatorProps> = ({ coordinator, setCoordinator }) => {
|
||||||
const { setOpen, hostUrl } = useContext<UseAppStoreType>(AppContext);
|
const { setOpen } = useContext<UseAppStoreType>(AppContext);
|
||||||
const { federation, sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
|
const { federation, sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|||||||
@ -94,7 +94,7 @@ const OrderDetails = ({
|
|||||||
currentOrder.amount > 0 ? false : currentOrder.has_range,
|
currentOrder.amount > 0 ? false : currentOrder.has_range,
|
||||||
currentOrder.min_amount,
|
currentOrder.min_amount,
|
||||||
currentOrder.max_amount,
|
currentOrder.max_amount,
|
||||||
) + ` ${currencyCode}`
|
) + ` ${String(currencyCode)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [orderUpdatedAt, currencyCode]);
|
}, [orderUpdatedAt, currencyCode]);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
interface Task {
|
interface Task {
|
||||||
robohash: Robohash;
|
robohash: Robohash;
|
||||||
resolves: ((result: string) => void)[];
|
resolves: Array<(result: string) => void>;
|
||||||
rejects: ((reason?: Error) => void)[];
|
rejects: Array<(reason?: Error) => void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Robohash {
|
interface Robohash {
|
||||||
@ -32,7 +32,7 @@ class RoboGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private assignTasksToWorkers() {
|
private assignTasksToWorkers(): void {
|
||||||
const availableWorker = this.workers.find((w) => !w.busy);
|
const availableWorker = this.workers.find((w) => !w.busy);
|
||||||
|
|
||||||
if (availableWorker) {
|
if (availableWorker) {
|
||||||
@ -42,13 +42,13 @@ class RoboGenerator {
|
|||||||
availableWorker.worker.postMessage(task.robohash);
|
availableWorker.worker.postMessage(task.robohash);
|
||||||
|
|
||||||
// Clean up the event listener and free the worker after receiving the result
|
// Clean up the event listener and free the worker after receiving the result
|
||||||
const cleanup = () => {
|
const cleanup = (): void => {
|
||||||
availableWorker.worker.removeEventListener('message', completionCallback);
|
availableWorker.worker.removeEventListener('message', completionCallback);
|
||||||
availableWorker.busy = false;
|
availableWorker.busy = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolve the promise when the task is completed
|
// Resolve the promise when the task is completed
|
||||||
const completionCallback = (event: MessageEvent) => {
|
const completionCallback = (event: MessageEvent): void => {
|
||||||
if (event.data.cacheKey === task.robohash.cacheKey) {
|
if (event.data.cacheKey === task.robohash.cacheKey) {
|
||||||
const { cacheKey, imageUrl } = event.data;
|
const { cacheKey, imageUrl } = event.data;
|
||||||
|
|
||||||
@ -57,7 +57,9 @@ class RoboGenerator {
|
|||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
task.resolves.forEach((f) => f(imageUrl));
|
task.resolves.forEach((f) => {
|
||||||
|
f(imageUrl);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +69,9 @@ class RoboGenerator {
|
|||||||
availableWorker.worker.addEventListener('error', (error) => {
|
availableWorker.worker.addEventListener('error', (error) => {
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
task.rejects.forEach((f) => f(new Error(error.message)));
|
task.rejects.forEach((f) => {
|
||||||
|
f(new Error(error.message));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +85,7 @@ class RoboGenerator {
|
|||||||
if (this.assetsCache[cacheKey]) {
|
if (this.assetsCache[cacheKey]) {
|
||||||
return this.assetsCache[cacheKey];
|
return this.assetsCache[cacheKey];
|
||||||
} else {
|
} else {
|
||||||
return new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
let task = this.queue.find((t) => t.robohash.cacheKey === cacheKey);
|
let task = this.queue.find((t) => t.robohash.cacheKey === cacheKey);
|
||||||
|
|
||||||
if (!task) {
|
if (!task) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { Avatar, Badge, Tooltip } from '@mui/material';
|
|||||||
import { SendReceiveIcon } from '../Icons';
|
import { SendReceiveIcon } from '../Icons';
|
||||||
import placeholder from './placeholder.json';
|
import placeholder from './placeholder.json';
|
||||||
import { robohash } from './RobohashGenerator';
|
import { robohash } from './RobohashGenerator';
|
||||||
import { AppContext, UseAppStoreType } from '../../contexts/AppContext';
|
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
shortAlias?: string | undefined;
|
shortAlias?: string | undefined;
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
import { async_generate_robohash } from 'robo-identities-wasm';
|
import { async_generate_robohash } from 'robo-identities-wasm';
|
||||||
|
|
||||||
// Listen for messages from the main thread
|
// Listen for messages from the main thread
|
||||||
self.addEventListener('message', async (event) => {
|
self.addEventListener('message', (event) => {
|
||||||
const { hash, size, cacheKey, workerIndex } = event.data;
|
void (async () => {
|
||||||
|
const { hash, size, cacheKey } = event.data;
|
||||||
|
|
||||||
// Generate the image using async_image_base
|
// Generate the image using async_image_base
|
||||||
const t0 = performance.now();
|
const t0 = performance.now();
|
||||||
const avatarB64 = await async_generate_robohash(hash, size == 'small' ? 80 : 256);
|
const avatarB64: string = await async_generate_robohash(hash, size === 'small' ? 80 : 256);
|
||||||
const imageUrl = `data:image/png;base64,${avatarB64}`;
|
const imageUrl = `data:image/png;base64,${avatarB64}`;
|
||||||
const t1 = performance.now();
|
const t1 = performance.now();
|
||||||
console.log(`Avatar generated in: ${t1 - t0} ms`);
|
console.log(`Avatar generated in: ${t1 - t0} ms`);
|
||||||
// Send the result back to the main thread
|
// Send the result back to the main thread
|
||||||
self.postMessage({ cacheKey, imageUrl });
|
self.postMessage({ cacheKey, imageUrl });
|
||||||
|
})();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -203,7 +203,7 @@ const RobotInfo: React.FC<Props> = ({ coordinator, onClose }: Props) => {
|
|||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
|
|
||||||
<ListItemText>
|
<ListItemText>
|
||||||
{Boolean(robot?.tgEnabled) ? (
|
{robot?.tgEnabled ? (
|
||||||
<Typography color={theme.palette.success.main}>
|
<Typography color={theme.palette.success.main}>
|
||||||
<b>{t('Telegram enabled')}</b>
|
<b>{t('Telegram enabled')}</b>
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -241,7 +241,7 @@ const RobotInfo: React.FC<Props> = ({ coordinator, onClose }: Props) => {
|
|||||||
<Switch
|
<Switch
|
||||||
checked={robot?.stealthInvoices}
|
checked={robot?.stealthInvoices}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
setStealthInvoice(!Boolean(robot?.stealthInvoices));
|
setStealthInvoice(!robot?.stealthInvoices);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import {
|
|||||||
} from '@mui/icons-material';
|
} from '@mui/icons-material';
|
||||||
import { systemClient } from '../../services/System';
|
import { systemClient } from '../../services/System';
|
||||||
import SwapCalls from '@mui/icons-material/SwapCalls';
|
import SwapCalls from '@mui/icons-material/SwapCalls';
|
||||||
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';
|
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
||||||
|
|
||||||
interface SettingsFormProps {
|
interface SettingsFormProps {
|
||||||
dense?: boolean;
|
dense?: boolean;
|
||||||
@ -226,7 +226,7 @@ const SettingsForm = ({ dense = false }: SettingsFormProps): JSX.Element => {
|
|||||||
value={settings.network}
|
value={settings.network}
|
||||||
onChange={(e, network) => {
|
onChange={(e, network) => {
|
||||||
setSettings({ ...settings, network });
|
setSettings({ ...settings, network });
|
||||||
federation.updateUrls(origin, { ...settings, network }, hostUrl);
|
void federation.updateUrls(origin, { ...settings, network }, hostUrl);
|
||||||
systemClient.setItem('settings_network', network);
|
systemClient.setItem('settings_network', network);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -15,9 +15,12 @@ import ChatHeader from '../ChatHeader';
|
|||||||
import { type EncryptedChatMessage, type ServerMessage } from '..';
|
import { type EncryptedChatMessage, type ServerMessage } from '..';
|
||||||
import ChatBottom from '../ChatBottom';
|
import ChatBottom from '../ChatBottom';
|
||||||
import { sha256 } from 'js-sha256';
|
import { sha256 } from 'js-sha256';
|
||||||
import { Order } from '../../../../models';
|
import { type Order } from '../../../../models';
|
||||||
import { UseFederationStoreType, FederationContext } from '../../../../contexts/FederationContext';
|
import {
|
||||||
import { UseAppStoreType, AppContext } from '../../../../contexts/AppContext';
|
type UseFederationStoreType,
|
||||||
|
FederationContext,
|
||||||
|
} from '../../../../contexts/FederationContext';
|
||||||
|
import { type UseAppStoreType, AppContext } from '../../../../contexts/AppContext';
|
||||||
|
|
||||||
const audioPath =
|
const audioPath =
|
||||||
window.NativeRobosats === undefined
|
window.NativeRobosats === undefined
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import {
|
|||||||
FederationContext,
|
FederationContext,
|
||||||
} from '../../../../contexts/FederationContext';
|
} from '../../../../contexts/FederationContext';
|
||||||
import { type UseGarageStoreType, GarageContext } from '../../../../contexts/GarageContext';
|
import { type UseGarageStoreType, GarageContext } from '../../../../contexts/GarageContext';
|
||||||
import { Order } from '../../../../models';
|
import { type Order } from '../../../../models';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
order: Order;
|
order: Order;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Order, type Robot } from '../../../models';
|
import { type Order, type Robot } from '../../../models';
|
||||||
import EncryptedSocketChat from './EncryptedSocketChat';
|
import EncryptedSocketChat from './EncryptedSocketChat';
|
||||||
import EncryptedTurtleChat from './EncryptedTurtleChat';
|
import EncryptedTurtleChat from './EncryptedTurtleChat';
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,10 @@ import { LoadingButton } from '@mui/lab';
|
|||||||
|
|
||||||
import { type Order } from '../../../models';
|
import { type Order } from '../../../models';
|
||||||
import { systemClient } from '../../../services/System';
|
import { systemClient } from '../../../services/System';
|
||||||
import { FederationContext, UseFederationStoreType } from '../../../contexts/FederationContext';
|
import {
|
||||||
|
FederationContext,
|
||||||
|
type UseFederationStoreType,
|
||||||
|
} from '../../../contexts/FederationContext';
|
||||||
|
|
||||||
interface SuccessfulPromptProps {
|
interface SuccessfulPromptProps {
|
||||||
order: Order;
|
order: Order;
|
||||||
|
|||||||
@ -156,7 +156,7 @@ const TradeBox = ({ baseUrl, onStartAgain }: TradeBoxProps): JSX.Element => {
|
|||||||
|
|
||||||
const renewOrder = function (): void {
|
const renewOrder = function (): void {
|
||||||
const currentOrder = garage.getSlot()?.order;
|
const currentOrder = garage.getSlot()?.order;
|
||||||
if (Boolean(currentOrder)) {
|
if (currentOrder) {
|
||||||
const body = {
|
const body = {
|
||||||
type: currentOrder.type,
|
type: currentOrder.type,
|
||||||
currency: currentOrder.currency,
|
currency: currentOrder.currency,
|
||||||
|
|||||||
Reference in New Issue
Block a user