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:
@@ -38,11 +38,11 @@ export default function App({ onSwitchToGame, onSwitchToWorkshop }) {
|
|||||||
return unsub;
|
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(() => {
|
useEffect(() => {
|
||||||
|
if (state.modules.length > 0) return; // Already loaded (Workshop, etc.)
|
||||||
const loaded = autoLoad();
|
const loaded = autoLoad();
|
||||||
if (!loaded || state.modules.length === 0) {
|
if (!loaded || state.modules.length === 0) {
|
||||||
// Load chiptune demo preset
|
|
||||||
deserialize(CHIPTUNE_PRESET);
|
deserialize(CHIPTUNE_PRESET);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user