Got download in progress dialog working on squeak address page (#1732)

* Got download in progress dialog working on squeak address page

* Got progresss indicator working for download replies

* Got progresss indicator working for single squeak

* Separate function for hanlde download replies and click

* Run frontend lint

* Update frontend build

* Remove todo

* Update frontend build
This commit is contained in:
Jonathan Zernik 2021-10-26 13:10:14 -07:00 committed by GitHub
parent 79e59bdf97
commit 31cd1d93cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 219 additions and 72 deletions

View file

@ -19,7 +19,6 @@ import {
// styles
import useStyles from './styles';
export default function ConnectPeerDialog({
open,
handleClose,
@ -35,7 +34,7 @@ export default function ConnectPeerDialog({
const [customPortChecked, setCustomPortChecked] = useState(false);
const [useTorChecked, setUseTorChecked] = useState(false);
const [loading, setLoading] = useState(false);
const portToUse = useMemo(() => customPortChecked ? port : defaultPeerPort, [customPortChecked, port, defaultPeerPort]);
const portToUse = useMemo(() => (customPortChecked ? port : defaultPeerPort), [customPortChecked, port, defaultPeerPort]);
const getDefaultPeerPort = () => {
getDefaultPeerPortRequest(setDefaultPeerPort);
@ -75,10 +74,9 @@ export default function ConnectPeerDialog({
const getNetwork = (useTor) => {
if (useTor) {
return "TORV3";
} else {
return "IPV4";
return 'TORV3';
}
return 'IPV4';
};
const connectPeer = (peerName, host, port) => {
@ -87,7 +85,7 @@ export default function ConnectPeerDialog({
// console.log('portToUse: ', portToUse);
const network = getNetwork(useTorChecked);
setLoading(true);
console.log("Calling connectSqueakPeerRequest with:", network, host, port);
console.log('Calling connectSqueakPeerRequest with:', network, host, port);
connectSqueakPeerRequest(network, host, port, (response) => {
// goToPeerPage(history, response.getPeerId());
// handlePeerConnected();

View file

@ -42,7 +42,6 @@ const useStyles = makeStyles((theme) => ({
},
}));
export default function CreatePeerDialog({
open,
handleClose,
@ -60,7 +59,7 @@ export default function CreatePeerDialog({
const [port, setPort] = useState('');
const [customPortChecked, setCustomPortChecked] = useState(false);
const [useTorChecked, setUseTorChecked] = useState(false);
const portToUse = useMemo(() => customPortChecked ? port : defaultPeerPort, [customPortChecked, port, defaultPeerPort]);
const portToUse = useMemo(() => (customPortChecked ? port : defaultPeerPort), [customPortChecked, port, defaultPeerPort]);
const getDefaultPeerPort = () => {
getDefaultPeerPortRequest(setDefaultPeerPort);
@ -114,10 +113,9 @@ export default function CreatePeerDialog({
const getNetwork = (useTor) => {
if (useTor) {
return "TORV3";
} else {
return "IPV4";
return 'TORV3';
}
return 'IPV4';
};
const createPeer = (peerName, host, port) => {

View file

@ -0,0 +1,32 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
CircularProgress,
} from '@material-ui/core';
// styles
import useStyles from './styles';
export default function DownloadInProgressDialog({
open,
handleClose,
...props
}) {
const classes = useStyles();
return (
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
<DialogTitle id="form-dialog-title">Download in progress</DialogTitle>
<form className={classes.root} noValidate autoComplete="off">
<DialogContent>
Downloading...
</DialogContent>
<DialogContent>
<CircularProgress size={48} className={classes.buttonProgress} />
</DialogContent>
</form>
</Dialog>
);
}

View file

@ -0,0 +1,6 @@
{
"name": "DownloadInProgressDialog",
"version": "0.0.0",
"private": true,
"main": "DownloadInProgressDialog.js"
}

View file

@ -0,0 +1,43 @@
import { makeStyles } from '@material-ui/styles';
export default makeStyles((theme) => ({
widgetWrapper: {
display: 'flex',
minHeight: '100%',
},
widgetHeader: {
padding: theme.spacing(3),
paddingBottom: theme.spacing(1),
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
},
widgetRoot: {
boxShadow: theme.customShadows.widget,
},
widgetBody: {
paddingBottom: theme.spacing(3),
paddingRight: theme.spacing(3),
paddingLeft: theme.spacing(3),
},
noPadding: {
padding: 0,
},
paper: {
display: 'flex',
flexDirection: 'column',
flexGrow: 1,
overflow: 'hidden',
},
moreButton: {
margin: -theme.spacing(1),
padding: 0,
width: 40,
height: 40,
color: theme.palette.text.hint,
'&:hover': {
backgroundColor: theme.palette.primary.main,
color: 'rgba(255, 255, 255, 0.35)',
},
},
}));

View file

@ -23,10 +23,6 @@ import SqueakActionBar from '../SqueakActionBar';
import SqueakTime from '../SqueakTime';
import SqueakUserAvatar from '../SqueakUserAvatar';
import {
downloadSqueakRequest,
} from '../../squeakclient/requests';
import {
goToSqueakAddressPage,
} from '../../navigation/navigation';
@ -40,6 +36,7 @@ export default function SqueakDetailItem({
squeak,
network,
reloadSqueak,
handleDownloadAncestorsClick,
...props
}) {
const classes = useStyles();
@ -79,11 +76,7 @@ export default function SqueakDetailItem({
const onDownloadClick = (event) => {
event.preventDefault();
console.log('Handling download click...');
downloadSqueakRequest(hash, (response) => {
// TODO: Nothing for now. This will eventually show something
// when downloadSqueakRequest becomes a streaming method.
// reloadSqueak();
});
handleDownloadAncestorsClick();
};
const handleCloseUnlockedSnackbar = (event, reason) => {

View file

@ -55,9 +55,9 @@ export default function TransactionItem({
function TransactionMoreDetails() {
return (
<CardContent
className={classes.cardContent}
onClick={onMoreDetailsClick}
>
className={classes.cardContent}
onClick={onMoreDetailsClick}
>
{TransactionDetailItem('Tx Hash', transaction.getTxHash())}
{TransactionDetailItem('Timestamp', moment.unix(transaction.getTimeStamp()).format('lll'))}
{TransactionDetailItem('Block Height', transaction.getBlockHeight())}

View file

@ -139,25 +139,27 @@ export default function PeerPage() {
const network = peer.getPeerAddress().getNetwork();
return (
<>
<div className={classes.root}>
Peer Address:
<Button
variant="contained"
onClick={() => {
goToPeerAddressPage(
history,
peer.getPeerAddress().getNetwork(),
peer.getPeerAddress().getHost(),
peer.getPeerAddress().getPort(),
);
}}
>
{peerAddressStr}
</Button>
</div>
<div className={classes.root}>
Network: {network}
</div>
<div className={classes.root}>
Peer Address:
<Button
variant="contained"
onClick={() => {
goToPeerAddressPage(
history,
peer.getPeerAddress().getNetwork(),
peer.getPeerAddress().getHost(),
peer.getPeerAddress().getPort(),
);
}}
>
{peerAddressStr}
</Button>
</div>
<div className={classes.root}>
Network:
{' '}
{network}
</div>
</>
);
}

View file

@ -62,7 +62,7 @@ export default function PeerAddressPage() {
const connectPeer = useCallback(() => {
setWaitingForConnectedPeer(true);
console.log("Calling connectSqueakPeerRequest with " + network, host, port);
console.log(`Calling connectSqueakPeerRequest with ${network}`, host, port);
connectSqueakPeerRequest(network, host, port, () => {
getConnectedPeer();
},

View file

@ -22,11 +22,13 @@ import useStyles from './styles';
import SqueakDetailItem from '../../components/SqueakDetailItem';
import SqueakThread from '../../components/SqueakThread';
import SqueakReplies from '../../components/SqueakReplies';
import DownloadInProgressDialog from '../../components/DownloadInProgressDialog';
import {
getAncestorSqueakDisplaysRequest,
getReplySqueakDisplaysRequest,
getNetworkRequest,
downloadSqueakRequest,
downloadRepliesRequest,
// subscribeReplySqueakDisplaysRequest,
// subscribeAncestorSqueakDisplaysRequest,
@ -42,6 +44,8 @@ export default function SqueakPage() {
const [network, setNetwork] = useState('');
const [waitingForSqueak, setWaitingForSqueak] = useState(false);
const [waitingForReplySqueaks, setWaitingForReplySqueaks] = useState(false);
const [waitingForDownloadAncestors, setWaitingForDownloadAncestors] = useState(false);
const [waitingForDownloadReplies, setWaitingForDownloadReplies] = useState(false);
const getAncestorSqueaks = useCallback((hash) => {
setWaitingForSqueak(true);
@ -80,12 +84,37 @@ export default function SqueakPage() {
});
};
const handleCloseAncestorsDownloadInProgressDialog = () => {
setWaitingForDownloadAncestors(false);
};
const handleCloseRepliesDownloadInProgressDialog = () => {
setWaitingForDownloadReplies(false);
};
const handleDownloadAncestors = () => {
console.log('Handling download ancestors click...');
setWaitingForDownloadAncestors(true);
downloadSqueakRequest(hash, (response) => {
setWaitingForDownloadAncestors(false);
setAncestorSqueaks(null); // Temporary fix until component unmounts correcyly
getAncestorSqueaks(hash);
});
};
const handleDownloadReplies = () => {
console.log('Handling download replies click...');
setWaitingForDownloadReplies(true);
downloadRepliesRequest(hash, (response) => {
setWaitingForDownloadReplies(false);
setReplySqueaks(null); // Temporary fix until component unmounts correcyly
getReplySqueaks(hash, SQUEAKS_PER_PAGE, null);
});
};
const onDownloadRepliesClick = (event) => {
event.preventDefault();
console.log('Handling download replies click...');
downloadRepliesRequest(hash, (response) => {
// Do nothing.
});
handleDownloadReplies();
};
const calculateCurrentSqueak = (ancestorSqueaks) => {
@ -136,6 +165,7 @@ export default function SqueakPage() {
squeak={currentSqueak}
reloadSqueak={getCurrentSqueak}
network={network}
handleDownloadAncestorsClick={handleDownloadAncestors}
/>
);
}
@ -196,6 +226,28 @@ export default function SqueakPage() {
);
}
function AncestorsDownloadInProgressDialogContent() {
return (
<>
<DownloadInProgressDialog
open={waitingForDownloadAncestors}
handleClose={handleCloseAncestorsDownloadInProgressDialog}
/>
</>
);
}
function RepliesDownloadInProgressDialogContent() {
return (
<>
<DownloadInProgressDialog
open={waitingForDownloadReplies}
handleClose={handleCloseRepliesDownloadInProgressDialog}
/>
</>
);
}
function ViewMoreSqueaksButton() {
return (
<>
@ -226,6 +278,8 @@ export default function SqueakPage() {
return (
<>
{GridContent()}
{AncestorsDownloadInProgressDialogContent()}
{RepliesDownloadInProgressDialogContent()}
</>
);
}

View file

@ -17,6 +17,7 @@ import GetAppIcon from '@material-ui/icons/GetApp';
import ReplayIcon from '@material-ui/icons/Replay';
import CreateContactProfileDialog from '../../components/CreateContactProfileDialog';
import DownloadInProgressDialog from '../../components/DownloadInProgressDialog';
import SqueakList from '../../components/SqueakList';
import useStyles from './styles';
@ -42,6 +43,7 @@ export default function SqueakAddressPage() {
const [createContactProfileDialogOpen, setCreateContactProfileDialogOpen] = useState(false);
const [network, setNetwork] = useState('');
const [waitingForSqueaks, setWaitingForSqueaks] = useState(false);
const [waitingForDownload, setWaitingForDownload] = useState(false);
const getSqueakProfile = (address) => {
getSqueakProfileByAddressRequest(address, setSqueakProfile);
@ -76,11 +78,18 @@ export default function SqueakAddressPage() {
setCreateContactProfileDialogOpen(false);
};
const handleCloseDownloadInProgressDialog = () => {
setWaitingForDownload(false);
};
const onDownloadSqueaksClick = (event) => {
event.preventDefault();
console.log('Handling download address squeaks click...');
setWaitingForDownload(true);
downloadAddressSqueaksRequest(address, (response) => {
// Do nothing.
setWaitingForDownload(false);
setSqueaks([]);
getSqueaks(address, SQUEAKS_PER_PAGE, null);
});
};
@ -160,6 +169,17 @@ export default function SqueakAddressPage() {
);
}
function DownloadInProgressDialogContent() {
return (
<>
<DownloadInProgressDialog
open={waitingForDownload}
handleClose={handleCloseDownloadInProgressDialog}
/>
</>
);
}
function GridContent() {
return (
<Grid container spacing={0}>
@ -248,6 +268,7 @@ export default function SqueakAddressPage() {
<>
{SqueakProfileContent()}
{AddressSqueaksContent()}
{DownloadInProgressDialogContent()}
</>
);
}

View file

@ -1,17 +1,17 @@
{
"files": {
"main.js": "/static/js/main.7e437b95.chunk.js",
"main.js.map": "/static/js/main.7e437b95.chunk.js.map",
"main.js": "/static/js/main.ea3767aa.chunk.js",
"main.js.map": "/static/js/main.ea3767aa.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.9f0ba400.js",
"runtime-main.js.map": "/static/js/runtime-main.9f0ba400.js.map",
"static/css/2.15110fae.chunk.css": "/static/css/2.15110fae.chunk.css",
"static/js/2.866ca676.chunk.js": "/static/js/2.866ca676.chunk.js",
"static/js/2.866ca676.chunk.js.map": "/static/js/2.866ca676.chunk.js.map",
"static/js/2.da272a6c.chunk.js": "/static/js/2.da272a6c.chunk.js",
"static/js/2.da272a6c.chunk.js.map": "/static/js/2.da272a6c.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.05885cb75453f54e1187e38d9c886870.js": "/precache-manifest.05885cb75453f54e1187e38d9c886870.js",
"precache-manifest.36c1aa5e0a5bc62082b13dce7273cbbe.js": "/precache-manifest.36c1aa5e0a5bc62082b13dce7273cbbe.js",
"service-worker.js": "/service-worker.js",
"static/css/2.15110fae.chunk.css.map": "/static/css/2.15110fae.chunk.css.map",
"static/js/2.866ca676.chunk.js.LICENSE.txt": "/static/js/2.866ca676.chunk.js.LICENSE.txt",
"static/js/2.da272a6c.chunk.js.LICENSE.txt": "/static/js/2.da272a6c.chunk.js.LICENSE.txt",
"static/media/font-awesome.min.css": "/static/media/fontawesome-webfont.fee66e71.woff",
"static/media/google.svg": "/static/media/google.695a3160.svg",
"static/media/logo.svg": "/static/media/logo.a0185b04.svg"
@ -19,7 +19,7 @@
"entrypoints": [
"static/js/runtime-main.9f0ba400.js",
"static/css/2.15110fae.chunk.css",
"static/js/2.866ca676.chunk.js",
"static/js/main.7e437b95.chunk.js"
"static/js/2.da272a6c.chunk.js",
"static/js/main.ea3767aa.chunk.js"
]
}

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><meta name="description" content="Squeaknode is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.866ca676.chunk.js"></script><script src="/static/js/main.7e437b95.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><meta name="description" content="Squeaknode is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.da272a6c.chunk.js"></script><script src="/static/js/main.ea3767aa.chunk.js"></script></body></html>

View file

@ -1,23 +1,23 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "5cd86e7a7cbc821474780adf5057c85a",
"revision": "77fdb1dd37781e75b087191a1ff54205",
"url": "/index.html"
},
{
"revision": "a60018a947174cd7e1f9",
"revision": "b2d231408fcfce520381",
"url": "/static/css/2.15110fae.chunk.css"
},
{
"revision": "a60018a947174cd7e1f9",
"url": "/static/js/2.866ca676.chunk.js"
"revision": "b2d231408fcfce520381",
"url": "/static/js/2.da272a6c.chunk.js"
},
{
"revision": "ce334ad48c4dc2f747f813c26790dfba",
"url": "/static/js/2.866ca676.chunk.js.LICENSE.txt"
"url": "/static/js/2.da272a6c.chunk.js.LICENSE.txt"
},
{
"revision": "dc4843367f68074084f5",
"url": "/static/js/main.7e437b95.chunk.js"
"revision": "a8ec0c9f76aae229dcad",
"url": "/static/js/main.ea3767aa.chunk.js"
},
{
"revision": "cc9816de5a8639d377ea",

View file

@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts(
"/precache-manifest.05885cb75453f54e1187e38d9c886870.js"
"/precache-manifest.36c1aa5e0a5bc62082b13dce7273cbbe.js"
);
self.addEventListener('message', (event) => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long