feat: update mountOnDevice function to set device URL directly from mountEntry path and enable device if not already enabled

This commit is contained in:
Jaime Idolpx 2026-06-07 22:07:13 -04:00
parent 0bbf8896ea
commit 8ea3e3bc3c

View File

@ -29,7 +29,6 @@ import {
createFolder, createFolder,
deletePath, deletePath,
getFileContents, getFileContents,
getWebDAVBaseUrl,
humanFileSize, humanFileSize,
joinPath, joinPath,
listDirectory, listDirectory,
@ -295,13 +294,14 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
// Mount disk image onto a drive device // Mount disk image onto a drive device
const mountOnDevice = (deviceType: 'drive' | 'meatloaf', key: string) => { const mountOnDevice = (deviceType: 'drive' | 'meatloaf', key: string) => {
if (!mountEntry || !setConfig || !config) return; if (!mountEntry || !setConfig || !config) return;
const url = `${getWebDAVBaseUrl()}${mountEntry.path}`;
const newConfig = JSON.parse(JSON.stringify(config)); const newConfig = JSON.parse(JSON.stringify(config));
if (!newConfig.iec) newConfig.iec = {}; if (!newConfig.iec) newConfig.iec = {};
if (!newConfig.iec.devices) newConfig.iec.devices = {}; if (!newConfig.iec.devices) newConfig.iec.devices = {};
if (!newConfig.iec.devices[deviceType]) newConfig.iec.devices[deviceType] = {}; if (!newConfig.iec.devices[deviceType]) newConfig.iec.devices[deviceType] = {};
if (!newConfig.iec.devices[deviceType][key]) newConfig.iec.devices[deviceType][key] = {}; if (!newConfig.iec.devices[deviceType][key]) newConfig.iec.devices[deviceType][key] = {};
newConfig.iec.devices[deviceType][key].url = url; const dev = newConfig.iec.devices[deviceType][key];
dev.url = mountEntry.path;
if (!dev.enabled) dev.enabled = 1;
setConfig(newConfig); setConfig(newConfig);
toast.success(`Mounted "${mountEntry.name}" on device #${key}`); toast.success(`Mounted "${mountEntry.name}" on device #${key}`);
setMountEntry(null); setMountEntry(null);