Small fixes

This commit is contained in:
Reckless_Satoshi 2022-10-30 10:46:05 -07:00
parent d64adfc2bf
commit a5b63aed93
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
8 changed files with 83 additions and 46 deletions

View File

@ -632,20 +632,22 @@ class UserView(APIView):
context = {"bad_request": "Invalid serializer"} context = {"bad_request": "Invalid serializer"}
return Response(context, status=status.HTTP_400_BAD_REQUEST) return Response(context, status=status.HTTP_400_BAD_REQUEST)
# Deprecated
#
# If an existing user opens the main page by mistake, we do not want it to create a new nickname/profile for him # If an existing user opens the main page by mistake, we do not want it to create a new nickname/profile for him
if request.user.is_authenticated: # if request.user.is_authenticated:
context = {"nickname": request.user.username} # context = {"nickname": request.user.username}
not_participant, _, order = Logics.validate_already_maker_or_taker( # not_participant, _, order = Logics.validate_already_maker_or_taker(
request.user # request.user
) # )
# Does not allow this 'mistake' if an active order # # Does not allow this 'mistake' if an active order
if not not_participant: # if not not_participant:
context["active_order_id"] = order.id # context["active_order_id"] = order.id
context[ # context[
"bad_request" # "bad_request"
] = f"You are already logged in as {request.user} and have an active order" # ] = f"You are already logged in as {request.user} and have an active order"
return Response(context, status.HTTP_400_BAD_REQUEST) # return Response(context, status.HTTP_400_BAD_REQUEST)
# The new way. The token is never sent. Only its SHA256 # The new way. The token is never sent. Only its SHA256
token_sha256 = serializer.data.get("token_sha256") token_sha256 = serializer.data.get("token_sha256")

View File

@ -101,7 +101,6 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
} }
fetchBook(); fetchBook();
fetchLimits(); fetchLimits();
fetchInfo();
return () => { return () => {
if (typeof window !== undefined) { if (typeof window !== undefined) {
window.removeEventListener('resize', onResize); window.removeEventListener('resize', onResize);
@ -152,6 +151,10 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
}); });
}; };
useEffect(() => {
fetchInfo();
}, [open.stats, open.coordinator]);
const fetchRobot = function () { const fetchRobot = function () {
const requestBody = { const requestBody = {
token_sha256: sha256(robot.token), token_sha256: sha256(robot.token),
@ -194,8 +197,6 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
} }
}, []); }, []);
console.log(page);
return ( return (
<Router basename={basename}> <Router basename={basename}>
{/* load robot avatar image, set avatarLoaded: true */} {/* load robot avatar image, set avatarLoaded: true */}

View File

@ -53,7 +53,7 @@ const NavBar = ({
const smallBar = width < 50; const smallBar = width < 50;
const tabSx = smallBar const tabSx = smallBar
? { position: 'relative', bottom: nickname ? '0.8em' : '0em', minWidth: '1em' } ? { position: 'relative', bottom: nickname ? '1em' : '0em', minWidth: '1em' }
: { position: 'relative', bottom: '1em', minWidth: '2em' }; : { position: 'relative', bottom: '1em', minWidth: '2em' };
const pagesPosition = { const pagesPosition = {
robot: 1, robot: 1,
@ -103,12 +103,13 @@ const NavBar = ({
<Tab <Tab
sx={{ ...tabSx, minWidth: '2.5em', width: '2.5em', maxWidth: '4em' }} sx={{ ...tabSx, minWidth: '2.5em', width: '2.5em', maxWidth: '4em' }}
value='none' value='none'
disabled={nickname === null}
onClick={() => setOpen({ ...closeAll, profile: !open.profile })} onClick={() => setOpen({ ...closeAll, profile: !open.profile })}
icon={ icon={
nickname ? ( nickname ? (
<RobotAvatar <RobotAvatar
style={{ width: '2.3em', height: '2.3em' }} style={{ width: '2.3em', height: '2.3em', position: 'relative', top: '0.2em' }}
avatarClass='phoneFlippedSmallAvatar' avatarClass={theme.palette.mode === 'dark' ? 'navBarAvatarDark' : 'navBarAvatar'}
nickname={nickname} nickname={nickname}
/> />
) : ( ) : (
@ -160,7 +161,6 @@ const NavBar = ({
label={smallBar ? undefined : t('More')} label={smallBar ? undefined : t('More')}
value='none' value='none'
onClick={(e) => { onClick={(e) => {
console.log(e);
open.more ? null : setOpen({ ...open, more: true }); open.more ? null : setOpen({ ...open, more: true });
}} }}
icon={ icon={

View File

@ -22,7 +22,11 @@ const SettingsPage = ({ settings, setSettings, windowSize }: SettingsPageProps):
> >
<Grid container> <Grid container>
<Grid item> <Grid item>
<SettingsForm settings={settings} setSettings={setSettings} /> <SettingsForm
settings={settings}
setSettings={setSettings}
networt={window.NativeRobosats}
/>
</Grid> </Grid>
</Grid> </Grid>
</Paper> </Paper>

View File

@ -42,7 +42,10 @@ class UserGenPage extends Component {
// Displays the existing one // Displays the existing one
if (this.props.robot.nickname != null) { if (this.props.robot.nickname != null) {
this.setState({ inputToken: this.props.robot.token }); this.setState({ inputToken: this.props.robot.token });
} else if (this.props.robot.token) { } else if (
this.props.robot.token ||
(window.NativeRobosats && systemClient.getCookie('robot_token'))
) {
this.setState({ inputToken: this.props.robot.token }); this.setState({ inputToken: this.props.robot.token });
this.getGeneratedUser(this.props.robot.token); this.getGeneratedUser(this.props.robot.token);
} else { } else {

View File

@ -4,7 +4,6 @@ import { useTheme } from '@mui/material/styles';
import { Link as LinkRouter } from 'react-router-dom'; import { Link as LinkRouter } from 'react-router-dom';
import { import {
Avatar,
Badge, Badge,
Button, Button,
CircularProgress, CircularProgress,
@ -102,10 +101,10 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
.post('/api/reward/', { .post('/api/reward/', {
invoice: rewardInvoice, invoice: rewardInvoice,
}) })
.then((data) => { .then((data: any) => {
setBadInvoice(data.bad_invoice); setBadInvoice(data.bad_invoice ?? '');
setShowRewardsSpinner(false); setShowRewardsSpinner(false);
setWithdrawn(!!data.successful_withdrawal); setWithdrawn(data.successful_withdrawal);
setOpenClaimRewards(!data.successful_withdrawal); setOpenClaimRewards(!data.successful_withdrawal);
setRobot({ ...robot, earnedRewards: data.successful_withdrawal ? 0 : robot.earnedRewards }); setRobot({ ...robot, earnedRewards: data.successful_withdrawal ? 0 : robot.earnedRewards });
}); });

View File

@ -29,9 +29,15 @@ interface SettingsFormProps {
dense?: boolean; dense?: boolean;
settings: Settings; settings: Settings;
setSettings: (state: Settings) => void; setSettings: (state: Settings) => void;
network?: boolean;
} }
const SettingsForm = ({ dense = false, settings, setSettings }: SettingsFormProps): JSX.Element => { const SettingsForm = ({
dense = false,
settings,
setSettings,
network = false,
}: SettingsFormProps): JSX.Element => {
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation(); const { t } = useTranslation();
const fontSizes = [ const fontSizes = [
@ -123,24 +129,27 @@ const SettingsForm = ({ dense = false, settings, setSettings }: SettingsFormProp
track={false} track={false}
/> />
</ListItem> </ListItem>
{network ? (
<ListItem> <ListItem>
<ListItemIcon> <ListItemIcon>
<Link /> <Link />
</ListItemIcon> </ListItemIcon>
<ToggleButtonGroup <ToggleButtonGroup
exclusive={true} exclusive={true}
value={settings.network} value={settings.network}
onChange={(e, value) => setSettings({ ...settings, network: value })} onChange={(e, value) => setSettings({ ...settings, network: value })}
> >
<ToggleButton value='mainnet' color='primary'> <ToggleButton value='mainnet' color='primary'>
{t('Mainnet')} {t('Mainnet')}
</ToggleButton> </ToggleButton>
<ToggleButton value='testnet' color='secondary'> <ToggleButton value='testnet' color='secondary'>
{t('Testnet')} {t('Testnet')}
</ToggleButton> </ToggleButton>
</ToggleButtonGroup> </ToggleButtonGroup>
</ListItem> </ListItem>
) : (
<></>
)}
</List> </List>
</Grid> </Grid>
</Grid> </Grid>

View File

@ -117,14 +117,14 @@ input[type='number'] {
filter: drop-shadow(0.5px 0.5px 0.5px #000000); filter: drop-shadow(0.5px 0.5px 0.5px #000000);
} }
.phoneFlippedSmallAvatar img { .navBarAvatar img {
transform: scaleX(-1); transform: scaleX(-1);
border: 1.3px solid #1976d2; border: 1.3px solid #1976d2;
-webkit-filter: grayscale(100%); -webkit-filter: grayscale(100%);
filter: grayscale(100%) brightness(150%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000); filter: grayscale(100%) brightness(150%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000);
} }
.phoneFlippedSmallAvatar:after { .navBarAvatar:after {
content: ''; content: '';
position: absolute; position: absolute;
top: 0; top: 0;
@ -136,6 +136,25 @@ input[type='number'] {
box-shadow: inset 0px 0px 35px rgb(255, 255, 255); box-shadow: inset 0px 0px 35px rgb(255, 255, 255);
} }
.navBarAvatarDark img {
transform: scaleX(-1);
border: 1.3px solid #90caf9;
-webkit-filter: grayscale(100%);
filter: grayscale(100%) brightness(100%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000);
}
.navBarAvatarDark:after {
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
border-radius: 50%;
border: 2.4px solid #90caf9;
box-shadow: inset 0px 0px 35px rgb(255, 255, 255);
}
.MuiButton-textInherit { .MuiButton-textInherit {
color: '#111111'; color: '#111111';
} }