diff --git a/src/main.js b/src/main.js index 7618d3a..8d4b875 100644 --- a/src/main.js +++ b/src/main.js @@ -358,6 +358,17 @@ async function pathToObjectUrl(path) { return convertFileSrc(path); } +function applyPromptFromMap(item) { + promptInput.value = typeof item?.prompt === 'string' ? item.prompt : ''; +} + +function loadMapItem(item, fileUrl, statusPrefix = 'Loaded') { + currentMapPath = item.path; + applyPromptFromMap(item); + setSkyFromUrl(fileUrl); + setStatus(`${statusPrefix} ${item.filename}`); +} + function resetProgressState() { progressState = { upscale: null, @@ -468,23 +479,17 @@ async function refreshThumbnails(selectedPath, shouldLoadSelection = true) { el.title = item.filename; el.addEventListener('click', () => { if (fileUrl) { - currentMapPath = item.path; - setSkyFromUrl(fileUrl); - setStatus(`Loaded ${item.filename}`); + loadMapItem(item, fileUrl); } }); thumbList.appendChild(el); if (fileUrl) { if (shouldLoadSelection && idx === 0 && !selectedPath) { - currentMapPath = item.path; - setSkyFromUrl(fileUrl); - setStatus(`Showing ${item.filename}`); + loadMapItem(item, fileUrl, 'Showing'); } if (shouldLoadSelection && selectedPath && selectedPath === item.path) { - currentMapPath = item.path; - setSkyFromUrl(fileUrl); - setStatus(`Showing ${item.filename}`); + loadMapItem(item, fileUrl, 'Showing'); } } }