controller: restore useConfigs and useDownloads

The toggle-hook de-duplication replaced a range of customHooks.js that also
contained these two unrelated hooks, breaking the production build. Restored
byte-identical from master; exports now match master exactly.

Jest missed this because it only compiles what tests import — `npm run build`
is what catches a missing export.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-29 19:41:55 -06:00
parent 07af0c9f28
commit 540081203f
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -1024,6 +1024,72 @@ export const useBrowseFiles = () => {
return {browseFiles, openFolders, setOpenFolders, fetchFiles};
}
export const useConfigs = () => {
const [configs, setConfigs] = useState(null);
const [loading, setLoading] = useState(false);
const fetchConfigs = async () => {
setLoading(true);
console.log('fetching configs...');
try {
const data = await getConfigs();
setConfigs(data['configs']);
console.debug('fetching configs successful');
} catch (e) {
// Ignore SyntaxError because they happen when the API is down.
if (!(e instanceof SyntaxError)) {
console.error(e);
}
setConfigs(undefined);
} finally {
setLoading(false);
}
}
const importConfig = async (fileName) => {
try {
await postImportConfig(fileName);
} catch (e) {
console.error(e);
}
}
const saveConfig = async (fileName) => {
try {
await postDumpConfig(fileName);
} catch (e) {
console.error(e);
}
}
return {configs, loading, fetchConfigs, importConfig, saveConfig}
}
export const useDownloads = () => {
const [onceDownloads, setOnceDownloads] = useState(null);
const [recurringDownloads, setRecurringDownloads] = useState(null);
const [pendingOnceDownloads, setPendingOnceDownloads] = useState(null);
const fetchDownloads = async () => {
try {
const data = await getDownloads();
setOnceDownloads(data['once_downloads']);
setRecurringDownloads(data['recurring_downloads']);
setPendingOnceDownloads(data['pending_once_downloads']);
} catch (e) {
console.error(e);
// Display errors.
setOnceDownloads(undefined);
setRecurringDownloads(undefined);
setPendingOnceDownloads(undefined);
}
}
useRecurringTimeout(fetchDownloads, 3 * 1000);
return {onceDownloads, recurringDownloads, pendingOnceDownloads, fetchDownloads}
}
// Every hardware toggle works the same way: one field of the shared status object
// says whether the subsystem is on, and starting/stopping it is a Controller call.
// `on` is null when the status is unknown, which the UI renders as unsupported.