Improve routing within app components

This commit is contained in:
Reckless_Satoshi 2022-01-31 04:53:20 -08:00
parent f03210b69d
commit 24347682c3
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
8 changed files with 35 additions and 30 deletions

View File

@ -81,7 +81,7 @@ class LNNode():
memo=description, memo=description,
value=num_satoshis, value=num_satoshis,
hash=r_hash, hash=r_hash,
expiry=int(invoice_expiry*1.15), # actual expiry is padded by 15% expiry=int(invoice_expiry*1.5), # actual expiry is padded by 50%, if tight, wrong client system clock will say invoice is expired.
cltv_expiry=cltv_expiry_blocks, cltv_expiry=cltv_expiry_blocks,
) )
response = cls.invoicesstub.AddHoldInvoice(request, metadata=[('macaroon', MACAROON.hex())]) response = cls.invoicesstub.AddHoldInvoice(request, metadata=[('macaroon', MACAROON.hex())])

View File

@ -21,7 +21,7 @@ def users_cleansing():
for user in queryset: for user in queryset:
if not user.profile.total_contracts == 0: if not user.profile.total_contracts == 0:
continue continue
valid, _ = Logics.validate_already_maker_or_taker(user) valid, _, _ = Logics.validate_already_maker_or_taker(user)
if valid: if valid:
deleted_users.append(str(user)) deleted_users.append(str(user))
user.delete() user.delete()

View File

@ -20,12 +20,7 @@ export default class App extends Component {
render() { render() {
return ( return (
<> <>
<div className='appCenter'>
<HomePage setAppState={this.setAppState}/> <HomePage setAppState={this.setAppState}/>
</div>
<div className='bottomBar'>
<BottomBar {...this.state} setAppState={this.setAppState} />
</div>
</> </>
); );
} }

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import {Badge, TextField, ListItemAvatar, Avatar,Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, ListItemButton, Divider, Dialog, DialogContent} from "@mui/material"; import {Badge, TextField, ListItemAvatar, Avatar,Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, ListItemButton, Divider, Dialog, DialogContent} from "@mui/material";
import MediaQuery from 'react-responsive' import MediaQuery from 'react-responsive'
import { Link } from 'react-router-dom'
// Icons // Icons
import SettingsIcon from '@mui/icons-material/Settings'; import SettingsIcon from '@mui/icons-material/Settings';
@ -209,7 +210,7 @@ export default class BottomBar extends Component {
<Divider/> <Divider/>
{this.state.active_order_id ? {this.state.active_order_id ?
// TODO Link to router and do this.props.history.push // TODO Link to router and do this.props.history.push
<ListItemButton component="a" href={window.location.origin +'/order/'+this.state.active_order_id}> <ListItemButton onClick={this.handleClickCloseProfile} to={'/order/'+this.state.active_order_id} component={Link}>
<ListItemIcon> <ListItemIcon>
<Badge badgeContent="" color="primary"> <Badge badgeContent="" color="primary">
<NumbersIcon color="primary"/> <NumbersIcon color="primary"/>

View File

@ -1,24 +1,43 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { BrowserRouter as Router, Switch, Route, Link, Redirect } from "react-router-dom"; import { BrowserRouter as Router, Switch, Route, Link, Redirect,useHistory } from "react-router-dom";
import UserGenPage from "./UserGenPage"; import UserGenPage from "./UserGenPage";
import MakerPage from "./MakerPage"; import MakerPage from "./MakerPage";
import BookPage from "./BookPage"; import BookPage from "./BookPage";
import OrderPage from "./OrderPage"; import OrderPage from "./OrderPage";
import BottomBar from "./BottomBar";
export default class HomePage extends Component { export default class HomePage extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
nickname: null,
token: null,
}
}
setAppState=(newState)=>{
this.setState(newState)
}
redirectTo(location) {
this.props.history.push(location);
} }
render() { render() {
return ( return (
<Router > <Router >
<div className='appCenter'>
<Switch> <Switch>
<Route exact path='/' render={(props) => <UserGenPage setAppState={this.props.setAppState}/>}/> <Route exact path='/' render={(props) => <UserGenPage setAppState={this.setAppState}/>}/>
<Route path='/make' component={MakerPage}/> <Route path='/make' component={MakerPage}/>
<Route path='/book' component={BookPage}/> <Route path='/book' component={BookPage}/>
<Route path="/order/:orderId" component={OrderPage}/> <Route path="/order/:orderId" component={OrderPage}/>
</Switch> </Switch>
</div>
<div className='bottomBar'>
<BottomBar redirectTo={this.redirectTo} {...this.state} setAppState={this.setAppState} />
</div>
</Router> </Router>
); );
} }

View File

@ -40,15 +40,10 @@ export default class InfoDialog extends Component {
<Typography component="body2" variant="body2"> <Typography component="body2" variant="body2">
<p>It is a BTC/FIAT peer-to-peer exchange over lightning. It simplifies <p>It is a BTC/FIAT peer-to-peer exchange over lightning. It simplifies
matchmaking and minimizes the need of trust. RoboSats focuses in privacy and speed.</p> matchmaking and minimizes the need of trust. RoboSats focuses in privacy and speed.</p>
<Grid align="center"><div style={{maxWidth:'75%', maxHeight:'75%'}}> <img
<Image width='100%'
className='newAvatar' src={window.location.origin +'/static/assets/images/robosats_0.1.0_banner.png'}
disableError='true'
cover='true'
color='null'
src={window.location.origin +'/static/assets/images/robosats_0.1.0.png'}
/> />
</div></Grid>
<p>RoboSats is an open source project <a <p>RoboSats is an open source project <a
href='https://github.com/reckless-satoshi/robosats'>(GitHub).</a> href='https://github.com/reckless-satoshi/robosats'>(GitHub).</a>
</p> </p>

View File

@ -120,11 +120,6 @@ export default class OrderPage extends Component {
this.getOrderDetails(); this.getOrderDetails();
} }
// Fix to use proper react props
handleClickBackButton=()=>{
window.history.back();
}
// Countdown Renderer callback with condition // Countdown Renderer callback with condition
countdownRenderer = ({ total, hours, minutes, seconds, completed }) => { countdownRenderer = ({ total, hours, minutes, seconds, completed }) => {
if (completed) { if (completed) {
@ -506,7 +501,7 @@ export default class OrderPage extends Component {
<Button variant='contained' color='primary' onClick={this.handleClickTakeOrderButton}>Take Order</Button> <Button variant='contained' color='primary' onClick={this.handleClickTakeOrderButton}>Take Order</Button>
</Grid> </Grid>
<Grid item xs={12} align="center"> <Grid item xs={12} align="center">
<Button variant='contained' color='secondary' onClick={this.handleClickBackButton}>Back</Button> <Button variant='contained' color='secondary' onClick={this.props.history.goBack}>Back</Button>
</Grid> </Grid>
</Grid> </Grid>
} }
@ -573,7 +568,7 @@ export default class OrderPage extends Component {
<Typography component="subtitle2" variant="subtitle2" color="secondary" > <Typography component="subtitle2" variant="subtitle2" color="secondary" >
{this.state.bad_request}<br/> {this.state.bad_request}<br/>
</Typography> </Typography>
<Button variant='contained' color='secondary' onClick={this.handleClickBackButton}>Back</Button> <Button variant='contained' color='secondary' onClick={this.props.history.goBack}>Back</Button>
</div> </div>
: :
(this.state.is_participant ? (this.state.is_participant ?

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB