Fix exported data loading in web interface

Store exported data files with a hash in the filename to allow the new
caching stategy for static files to work with it and provide a manifest
for the web interface to find the exported files with.
This commit is contained in:
Hornwitser committed 2022-06-08 21:01:36 +02:00
1 parent 48a57bf16c
commit 2a221456d9
7 files changed
+71 -10

No files matched your search

@@ -0,0 +1,23 @@
import { useEffect, useState } from "react";
let exportManifestCache = null;
let emptyCache = {};
export function useExportManifest() {
let [exportManifest, setExportManifest] = useState(exportManifestCache || emptyCache);
useEffect(() => {
async function load() {
let response = await fetch(`${webRoot}api/export-manifest`);
if (response.ok) {
exportManifestCache = await response.json();
setExportManifest(exportManifestCache);
}
}
if (!exportManifestCache) {
load();
}
}, []);
return exportManifest;
}