fix: don't overwrite Workshop-loaded patch with autoLoad/chiptune

When switching from Workshop to Sandbox after loading a patch,
the Sandbox's useEffect was running autoLoad() which overwrote
the just-loaded patch. Now it skips if modules are already present.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jose Luis
2026-03-21 20:54:18 +01:00
parent e53ec600ad
commit b0522d8b0f

View File

@@ -38,11 +38,11 @@ export default function App({ onSwitchToGame, onSwitchToWorkshop }) {
return unsub;
}, []);
// Auto-load on mount, or load chiptune demo if empty
// Auto-load on mount, but skip if modules already loaded (e.g. from Workshop)
useEffect(() => {
if (state.modules.length > 0) return; // Already loaded (Workshop, etc.)
const loaded = autoLoad();
if (!loaded || state.modules.length === 0) {
// Load chiptune demo preset
deserialize(CHIPTUNE_PRESET);
}
}, []);