mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Small fixes and updates
This commit is contained in:
parent
9412764f1d
commit
74398a019c
4483
frontend/package-lock.json
generated
4483
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,7 @@ const RobotPage = (): JSX.Element => {
|
|||||||
setInputToken(robot.token);
|
setInputToken(robot.token);
|
||||||
}
|
}
|
||||||
if (robot.nickname == null && robot.token) {
|
if (robot.nickname == null && robot.token) {
|
||||||
fetchRobot({ action: 'login' });
|
fetchRobot({ action: 'generate' });
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAutocomplete } from '@mui/base/AutocompleteUnstyled';
|
import useAutocomplete from '@mui/base/useAutocomplete';
|
||||||
import { styled } from '@mui/material/styles';
|
import { styled } from '@mui/material/styles';
|
||||||
import { Button, Fade, Tooltip, Typography, Grow, useTheme } from '@mui/material';
|
import { Button, Fade, Tooltip, Typography, Grow, useTheme } from '@mui/material';
|
||||||
import { fiatMethods, swapMethods, PaymentIcon } from '../PaymentMethods';
|
import { fiatMethods, swapMethods, PaymentIcon } from '../PaymentMethods';
|
||||||
@ -92,9 +91,13 @@ const InputWrapper = styled('div')(
|
|||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
function Tag(props) {
|
interface TagProps {
|
||||||
|
label: string;
|
||||||
|
icon: string;
|
||||||
|
onDelete: () => void;
|
||||||
|
}
|
||||||
|
const Tag = ({ label, icon, onDelete, ...other }: TagProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { label, icon, onDelete, ...other } = props;
|
|
||||||
const iconSize = 1.5 * theme.typography.fontSize;
|
const iconSize = 1.5 * theme.typography.fontSize;
|
||||||
return (
|
return (
|
||||||
<div {...other}>
|
<div {...other}>
|
||||||
@ -105,12 +108,6 @@ function Tag(props) {
|
|||||||
<CloseIcon onClick={onDelete} />
|
<CloseIcon onClick={onDelete} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Tag.propTypes = {
|
|
||||||
label: PropTypes.string.isRequired,
|
|
||||||
icon: PropTypes.string.isRequired,
|
|
||||||
onDelete: PropTypes.func.isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledTag = styled(Tag)(
|
const StyledTag = styled(Tag)(
|
@ -396,6 +396,7 @@ export const AppContextProvider = ({
|
|||||||
}: fetchRobotProps) {
|
}: fetchRobotProps) {
|
||||||
const oldRobot = robot;
|
const oldRobot = robot;
|
||||||
const targetSlot = slot ?? currentSlot;
|
const targetSlot = slot ?? currentSlot;
|
||||||
|
const token = newToken ?? oldRobot.token;
|
||||||
if (action != 'refresh') {
|
if (action != 'refresh') {
|
||||||
setRobot(new Robot());
|
setRobot(new Robot());
|
||||||
}
|
}
|
||||||
@ -403,16 +404,16 @@ export const AppContextProvider = ({
|
|||||||
|
|
||||||
const requestBody = {};
|
const requestBody = {};
|
||||||
if (action == 'login' || action == 'refresh') {
|
if (action == 'login' || action == 'refresh') {
|
||||||
requestBody.token_sha256 = sha256(newToken ?? oldRobot.token);
|
requestBody.token_sha256 = sha256(token);
|
||||||
} else if (action == 'generate' && newToken != null) {
|
} else if (action == 'generate' && token != null) {
|
||||||
const strength = tokenStrength(newToken);
|
const strength = tokenStrength(token);
|
||||||
requestBody.token_sha256 = sha256(newToken);
|
requestBody.token_sha256 = sha256(token);
|
||||||
requestBody.unique_values = strength.uniqueValues;
|
requestBody.unique_values = strength.uniqueValues;
|
||||||
requestBody.counts = strength.counts;
|
requestBody.counts = strength.counts;
|
||||||
requestBody.length = newToken.length;
|
requestBody.length = token.length;
|
||||||
requestBody.ref_code = refCode;
|
requestBody.ref_code = refCode;
|
||||||
requestBody.public_key = newKeys.pubKey ?? oldRobot.pubkey;
|
requestBody.public_key = newKeys?.pubKey ?? oldRobot.pubKey;
|
||||||
requestBody.encrypted_private_key = newKeys.encPrivKey ?? oldRobot.encPrivKey;
|
requestBody.encrypted_private_key = newKeys?.encPrivKey ?? oldRobot.encPrivKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
apiClient.post(baseUrl, '/api/user/', requestBody).then((data: any) => {
|
apiClient.post(baseUrl, '/api/user/', requestBody).then((data: any) => {
|
||||||
@ -444,7 +445,7 @@ export const AppContextProvider = ({
|
|||||||
newRobot = {
|
newRobot = {
|
||||||
...oldRobot,
|
...oldRobot,
|
||||||
nickname: data.nickname,
|
nickname: data.nickname,
|
||||||
token: newToken ?? oldRobot.token,
|
token: token,
|
||||||
loading: false,
|
loading: false,
|
||||||
activeOrderId: data.active_order_id ?? null,
|
activeOrderId: data.active_order_id ?? null,
|
||||||
lastOrderId: data.last_order_id ?? null,
|
lastOrderId: data.last_order_id ?? null,
|
||||||
@ -473,7 +474,7 @@ export const AppContextProvider = ({
|
|||||||
if (open.profile || (robot.token && robot.nickname === null)) {
|
if (open.profile || (robot.token && robot.nickname === null)) {
|
||||||
fetchRobot({ action: 'refresh' }); // refresh/update existing robot
|
fetchRobot({ action: 'refresh' }); // refresh/update existing robot
|
||||||
} else if (robot.token && robot.encPrivKey && robot.pubKey) {
|
} else if (robot.token && robot.encPrivKey && robot.pubKey) {
|
||||||
fetchRobot({ action: 'refresh' }); // create new robot with existing token and keys (on network and coordinator change)
|
fetchRobot({ action: 'generate' }); // create new robot with existing token and keys (on network and coordinator change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [open.profile, baseUrl]);
|
}, [open.profile, baseUrl]);
|
||||||
|
Loading…
Reference in New Issue
Block a user