From fa190e4c42f169e68b0aaa5146c544b735904f19 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Thu, 24 Jul 2025 17:38:23 +0300 Subject: [akfs] Now it downloads after all fetches are complete automatically --- src/js/arching-kaos-file-system.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/js/arching-kaos-file-system.js b/src/js/arching-kaos-file-system.js index 4ec85d5..1c12a06 100644 --- a/src/js/arching-kaos-file-system.js +++ b/src/js/arching-kaos-file-system.js @@ -20,6 +20,8 @@ var final_array_seq = []; var status = []; var workspace = []; var output = ""; +var downloaded = false; +var ready = false; function drawWorkSpace() { @@ -48,6 +50,7 @@ function akfsReset() final_array_seq = []; status = []; workspace = []; + downloaded = false; output = ""; if ( document.querySelector('svg') !== null ) document.querySelector('svg').remove(); } @@ -57,9 +60,23 @@ export function akfsGetMap(hash) akfsReset(); drawWorkSpace(); archingKaosFetchBlob(akfsGetMapURL(hash), akfsFromMapGetLevelOneMapHash, [hash]) + setInterval(pollStatus, 5000); return hash; } +function pollStatus() +{ + if ( downloaded ) return; + for ( let x in status ) { + if ( status[x] === "working" ) { + console.log("Not ready!"); + return + } + } + console.log("Ready!"); + akfsWorkOnChunks(); +} + function akfsFromMapGetOriginalHash(reply, params) { const [ hash ] = params; @@ -123,7 +140,7 @@ function akfsSerializeChunks(hash) } else { - console.log(status); + // console.log(status); console.log('next call'); } } @@ -143,6 +160,7 @@ export function akfsWorkOnChunks() akfsSerializeChunks(thingy.root_hash); var data = makeUpData(); offerDownloadableData(data); + downloaded = true; console.log(workspace); } -- cgit v1.2.3