Skip to content

Commit

Permalink
Merge pull request #126 from rhashimoto/file-demo-tweaks
Browse files Browse the repository at this point in the history
File demo tweaks
  • Loading branch information
rhashimoto authored Nov 1, 2023
2 parents 5266fd8 + b1c181f commit 6dcc19e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demo/file/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script type="module" defer src="./index.js"></script>
</head>
<body>
<h1>Sample database importer</h1>
<h1>Sample database import/export</h1>
<div>
<input type="file" id="file-import">
</div>
Expand Down
6 changes: 4 additions & 2 deletions demo/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ const DBFILE_MAGIC = 'SQLite format 3\x00';
navigator.serviceWorker.register('service-worker.js', { type: 'module' });
(async function() {
// Enable the export button when the service worker is responding.
let delay = 25;
const start = performance.now();
while (true) {
let delay = 25;
const response = await fetch('./export?check=true');
if (response.ok) {
// @ts-ignore
document.getElementById('file-export').disabled = false;
return;
}
if (performance.now() - start > 60_000) throw new Error('service worker timeout');
await new Promise(resolve => setTimeout(resolve, delay));
delay = Math.min(delay * 2, 5000);
delay *= 2;
}
})();

Expand Down

0 comments on commit 6dcc19e

Please sign in to comment.