mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
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.
24 lines
541 B
React
24 lines
541 B
React
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;
|
|
}
|