SpeedCalc, kept playing after save. Now stops. Fixed.
This commit is contained in:
@@ -167,8 +167,12 @@ export default function SpeedCalculatorModal({ open, melody, builtMelody, archet
|
||||
// Reset on open — auto-load archetype CSV if available
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setCapturedMax(info.maxSpeed > 0 ? info.maxSpeed : null);
|
||||
setCapturedNormal(null);
|
||||
const max = info.maxSpeed > 0 ? info.maxSpeed : null;
|
||||
const min = info.minSpeed > 0 ? info.minSpeed : null;
|
||||
// Reverse-calculate Normal from MIN and MAX: normal = sqrt(min * max)
|
||||
const normal = (max !== null && min !== null) ? Math.round(Math.sqrt(min * max)) : null;
|
||||
setCapturedMax(max);
|
||||
setCapturedNormal(normal);
|
||||
setBinaryLoadError("");
|
||||
setCurrentStep(-1);
|
||||
setPlaying(false);
|
||||
@@ -315,11 +319,12 @@ export default function SpeedCalculatorModal({ open, melody, builtMelody, archet
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!capturedMax || !capturedNormal || !derivedMin) return;
|
||||
stopPlayback();
|
||||
setSaving(true);
|
||||
setSaveError("");
|
||||
setSaveSuccess(false);
|
||||
try {
|
||||
await api.put(`/melodies/${melody.id}`, {
|
||||
const body = {
|
||||
information: {
|
||||
...info,
|
||||
minSpeed: derivedMin,
|
||||
@@ -327,10 +332,11 @@ export default function SpeedCalculatorModal({ open, melody, builtMelody, archet
|
||||
},
|
||||
default_settings: melody.default_settings,
|
||||
type: melody.type,
|
||||
url: melody.url,
|
||||
uid: melody.uid,
|
||||
pid: melody.pid,
|
||||
});
|
||||
};
|
||||
if (melody.url) body.url = melody.url;
|
||||
await api.put(`/melodies/${melody.id}`, body);
|
||||
setSaveSuccess(true);
|
||||
setTimeout(() => onSaved(), 800);
|
||||
} catch (err) {
|
||||
|
||||
@@ -115,7 +115,7 @@ export default function BuildOnTheFlyModal({ open, melodyId, currentMelody, curr
|
||||
const { steps: stepCount, totalNotes } = computeStepsAndNotes(csv);
|
||||
if (currentMelody && csv) {
|
||||
const existingInfo = currentMelody.information || {};
|
||||
await api.put(`/melodies/${melodyId}`, {
|
||||
const body = {
|
||||
information: {
|
||||
...existingInfo,
|
||||
archetype_csv: csv,
|
||||
@@ -124,10 +124,11 @@ export default function BuildOnTheFlyModal({ open, melodyId, currentMelody, curr
|
||||
},
|
||||
default_settings: currentMelody.default_settings,
|
||||
type: currentMelody.type,
|
||||
url: currentMelody.url,
|
||||
uid: currentMelody.uid,
|
||||
pid: currentMelody.pid,
|
||||
});
|
||||
};
|
||||
if (currentMelody.url) body.url = currentMelody.url;
|
||||
await api.put(`/melodies/${melodyId}`, body);
|
||||
}
|
||||
|
||||
setStatusMsg("Done!");
|
||||
|
||||
@@ -63,7 +63,7 @@ export default function SelectArchetypeModal({ open, melodyId, currentMelody, cu
|
||||
const { steps, totalNotes } = computeStepsAndNotes(csv);
|
||||
if (currentMelody && csv) {
|
||||
const existingInfo = currentMelody.information || {};
|
||||
await api.put(`/melodies/${melodyId}`, {
|
||||
const body = {
|
||||
information: {
|
||||
...existingInfo,
|
||||
archetype_csv: csv,
|
||||
@@ -72,10 +72,11 @@ export default function SelectArchetypeModal({ open, melodyId, currentMelody, cu
|
||||
},
|
||||
default_settings: currentMelody.default_settings,
|
||||
type: currentMelody.type,
|
||||
url: currentMelody.url,
|
||||
uid: currentMelody.uid,
|
||||
pid: currentMelody.pid,
|
||||
});
|
||||
};
|
||||
if (currentMelody.url) body.url = currentMelody.url;
|
||||
await api.put(`/melodies/${melodyId}`, body);
|
||||
}
|
||||
|
||||
onSuccess({ name: archetype.name, pid: archetype.pid, steps, totalNotes, archetype_csv: csv });
|
||||
|
||||
Reference in New Issue
Block a user