mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21: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);
|
||||
}
|
||||
if (robot.nickname == null && robot.token) {
|
||||
fetchRobot({ action: 'login' });
|
||||
fetchRobot({ action: 'generate' });
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAutocomplete } from '@mui/base/AutocompleteUnstyled';
|
||||
import useAutocomplete from '@mui/base/useAutocomplete';
|
||||
import { styled } from '@mui/material/styles';
|
||||
import { Button, Fade, Tooltip, Typography, Grow, useTheme } from '@mui/material';
|
||||
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 { label, icon, onDelete, ...other } = props;
|
||||
const iconSize = 1.5 * theme.typography.fontSize;
|
||||
return (
|
||||
<div {...other}>
|
||||
@ -105,12 +108,6 @@ function Tag(props) {
|
||||
<CloseIcon onClick={onDelete} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Tag.propTypes = {
|
||||
label: PropTypes.string.isRequired,
|
||||
icon: PropTypes.string.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const StyledTag = styled(Tag)(
|
@ -396,6 +396,7 @@ export const AppContextProvider = ({
|
||||
}: fetchRobotProps) {
|
||||
const oldRobot = robot;
|
||||
const targetSlot = slot ?? currentSlot;
|
||||
const token = newToken ?? oldRobot.token;
|
||||
if (action != 'refresh') {
|
||||
setRobot(new Robot());
|
||||
}
|
||||
@ -403,16 +404,16 @@ export const AppContextProvider = ({
|
||||
|
||||
const requestBody = {};
|
||||
if (action == 'login' || action == 'refresh') {
|
||||
requestBody.token_sha256 = sha256(newToken ?? oldRobot.token);
|
||||
} else if (action == 'generate' && newToken != null) {
|
||||
const strength = tokenStrength(newToken);
|
||||
requestBody.token_sha256 = sha256(newToken);
|
||||
requestBody.token_sha256 = sha256(token);
|
||||
} else if (action == 'generate' && token != null) {
|
||||
const strength = tokenStrength(token);
|
||||
requestBody.token_sha256 = sha256(token);
|
||||
requestBody.unique_values = strength.uniqueValues;
|
||||
requestBody.counts = strength.counts;
|
||||
requestBody.length = newToken.length;
|
||||
requestBody.length = token.length;
|
||||
requestBody.ref_code = refCode;
|
||||
requestBody.public_key = newKeys.pubKey ?? oldRobot.pubkey;
|
||||
requestBody.encrypted_private_key = newKeys.encPrivKey ?? oldRobot.encPrivKey;
|
||||
requestBody.public_key = newKeys?.pubKey ?? oldRobot.pubKey;
|
||||
requestBody.encrypted_private_key = newKeys?.encPrivKey ?? oldRobot.encPrivKey;
|
||||
}
|
||||
|
||||
apiClient.post(baseUrl, '/api/user/', requestBody).then((data: any) => {
|
||||
@ -444,7 +445,7 @@ export const AppContextProvider = ({
|
||||
newRobot = {
|
||||
...oldRobot,
|
||||
nickname: data.nickname,
|
||||
token: newToken ?? oldRobot.token,
|
||||
token: token,
|
||||
loading: false,
|
||||
activeOrderId: data.active_order_id ?? null,
|
||||
lastOrderId: data.last_order_id ?? null,
|
||||
@ -473,7 +474,7 @@ export const AppContextProvider = ({
|
||||
if (open.profile || (robot.token && robot.nickname === null)) {
|
||||
fetchRobot({ action: 'refresh' }); // refresh/update existing robot
|
||||
} 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]);
|
||||
|
Loading…
Reference in New Issue
Block a user