fix(webapp): show save button while first exercise is in progress
Save button was gated on workout.length, which stays 0 until a second exercise is started (the transition that flushes the current exercise into workout[]). Single-exercise workouts had no reachable save path. Gate on workout.length OR currentExercise sets, and recompute visibility when sets are added/removed and on draft restore. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9ba5cdf769
commit
60171d9b1c
1 changed files with 9 additions and 5 deletions
|
|
@ -138,6 +138,7 @@ function restoreDraft() {
|
|||
if (details) details.open = true;
|
||||
}
|
||||
|
||||
updateSaveButtonVisibility();
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.warn("Failed to restore draft", e);
|
||||
|
|
@ -301,6 +302,7 @@ function addSetToDOM(reps, weight) {
|
|||
`;
|
||||
entry.querySelector(".btn-remove").addEventListener("click", () => {
|
||||
entry.remove();
|
||||
updateSaveButtonVisibility();
|
||||
tg.HapticFeedback.selectionChanged();
|
||||
saveDraft();
|
||||
});
|
||||
|
|
@ -325,6 +327,7 @@ function addSet() {
|
|||
const weight = parseWeight(weightInput.value);
|
||||
|
||||
addSetToDOM(reps, weight);
|
||||
updateSaveButtonVisibility();
|
||||
|
||||
repsInput.value = "";
|
||||
weightInput.value = weight ? String(weight) : "";
|
||||
|
|
@ -390,15 +393,16 @@ function finishCurrentExercise() {
|
|||
saveDraft();
|
||||
}
|
||||
|
||||
function updateSaveButtonVisibility() {
|
||||
const canSave = workout.length > 0 || getCurrentSets().length > 0;
|
||||
btnSaveWorkout.classList.toggle("hidden", !canSave);
|
||||
}
|
||||
|
||||
function renderWorkout() {
|
||||
workoutExercises.innerHTML = "";
|
||||
const hasAny = workout.length > 0 || currentExercise !== null;
|
||||
|
||||
if (workout.length === 0) {
|
||||
btnSaveWorkout.classList.add("hidden");
|
||||
} else {
|
||||
btnSaveWorkout.classList.remove("hidden");
|
||||
}
|
||||
updateSaveButtonVisibility();
|
||||
|
||||
// Show notes section when there's any workout activity
|
||||
if (hasAny) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue