Browse Source

More loading screen improvements

qdn
CalDescent 3 years ago
parent
commit
f6b9ff50c3
  1. 2
      src/main/java/org/qortal/api/resource/ArbitraryResource.java
  2. 13
      src/main/java/org/qortal/arbitrary/ArbitraryDataResource.java
  3. 1
      src/main/java/org/qortal/controller/arbitrary/ArbitraryDataManager.java
  4. 27
      src/main/resources/loading/index.html

2
src/main/java/org/qortal/api/resource/ArbitraryResource.java

@ -643,7 +643,7 @@ public class ArbitraryResource {
ArbitraryDataReader reader = new ArbitraryDataReader(name, ArbitraryDataFile.ResourceIdType.NAME, service, null);
try {
reader.loadSynchronously(false);
} catch (DataException | IOException | MissingDataException e) {
} catch (Exception e) {
// No need to handle exception, as it will be reflected in the status
}
}

13
src/main/java/org/qortal/arbitrary/ArbitraryDataResource.java

@ -68,7 +68,7 @@ public class ArbitraryDataResource {
// Check if we have all data locally for this resource
if (!this.allFilesDownloaded()) {
if (this.madeRecentRequest()) {
if (this.isDataPotentiallyAvailable()) {
return new ArbitraryResourceSummary(ArbitraryResourceStatus.DOWNLOADING);
}
return new ArbitraryResourceSummary(ArbitraryResourceStatus.MISSING_DATA);
@ -115,7 +115,12 @@ public class ArbitraryDataResource {
}
}
private boolean madeRecentRequest() {
/**
* Best guess as to whether data might be available
* This is only used to give an indication to the user of progress
* @return - whether data might be available on the network
*/
private boolean isDataPotentiallyAvailable() {
try {
this.fetchTransactions();
Long now = NTP.getTime();
@ -127,7 +132,9 @@ public class ArbitraryDataResource {
for (ArbitraryTransactionData transactionData : transactionDataList) {
long lastRequestTime = ArbitraryDataManager.getInstance().lastRequestForSignature(transactionData.getSignature());
if (now - lastRequestTime < 30 * 1000L) {
// If we haven't requested yet, or requested in the last 30 seconds, there's still a
// chance that data is on its way but hasn't arrived yet
if (lastRequestTime == 0 || now - lastRequestTime < 30 * 1000L) {
return true;
}
}

1
src/main/java/org/qortal/controller/arbitrary/ArbitraryDataManager.java

@ -666,6 +666,7 @@ public class ArbitraryDataManager extends Thread {
String peerAddress = peer.getPeerData().getAddress().toString();
LOGGER.info("Adding arbitrary peer: {} for signature {}", peerAddress, Base58.encode(signature));
ArbitraryPeerData arbitraryPeerData = new ArbitraryPeerData(signature, peer);
repository.discardChanges();
repository.getArbitraryRepository().save(arbitraryPeerData);
repository.saveChanges();
}

27
src/main/resources/loading/index.html

@ -5,7 +5,6 @@
<title>Loading...</title>
<style>
canvas {
position: absolute;
top: 0;
left: 0;
@ -80,13 +79,14 @@
textStatus = "Build failed. Please try again later.";
}
else if (json.status == "DOWNLOADING") {
textStatus = "Locating files in data network...";
retryInterval = 5000;
textStatus = "Locating and downloading files...";
retryInterval = 1000;
}
else if (json.status == "MISSING_DATA") {
textStatus = "Unable to locate files. Please try again later.";
textStatus = "Unable to locate all files. Please try again later.";
retryInterval = 10000;
document.getElementById("status").style.color = "red";
document.getElementById("c").style.opacity = "0.5";
}
else if (json.status == "DOWNLOADED") {
textStatus = "Files downloaded";
@ -115,7 +115,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-->
<!-- partial:index.partial.html -->
<canvas id=c></canvas>
<canvas id="c"></canvas>
<!-- partial -->
<script>
var w = c.width = window.innerWidth,
@ -125,8 +125,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
opts = {
len: 40, // Size
count: 50,
baseTime: 10,
count: 250,
baseTime: 40,
addedTime: 10,
dieChance: .05, // Lifetime
spawnChance: 1,
@ -137,7 +137,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
color: 'hsl(hue,100%,light%)',
baseLight: 50,
addedLight: 10, // [50-10,50+10]
shadowToTimePropMult: 6,
shadowToTimePropMult: 1,
baseLightInputMultiplier: .01,
addedLightInputMultiplier: .02,
@ -155,7 +155,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
baseRad = Math.PI * 2 / 6;
ctx.fillStyle = 'black'; // Fade in
ctx.fillStyle = 'white';
ctx.fillRect( 0, 0, w, h );
function loop() {
@ -166,7 +166,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
ctx.globalCompositeOperation = 'source-over';
ctx.shadowBlur = 0;
ctx.fillStyle = 'rgba(255,255,255,alp)'.replace( 'alp', opts.repaintAlpha );
ctx.fillStyle = 'rgba(230,230,230,alp)'.replace( 'alp', opts.repaintAlpha );
ctx.fillRect( 0, 0, w, h );
ctx.globalCompositeOperation = 'darker';
@ -250,8 +250,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<div id="panel-outer">
<div id="panel">
<h1>Loading</h1>
<p>This page will refresh automatically when the content becomes available</p>
<h2>Loading</h2>
<p>
Files are being retrieved from the Qortal Data Network.
This page will refresh automatically when the content becomes available.
</p>
<p><span id="status">Loading...</span></p>
</div>
</div>

Loading…
Cancel
Save