feat(webapp): settings toggle for the +/- weight button
Users on devices with a proper numeric+sign keyboard (most Android, desktop) don't need the +/- button and may find it clutter. Added a "Negative weight button" toggle in Settings; default on. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6f9d04a0bf
commit
4320b14441
2 changed files with 24 additions and 2 deletions
|
|
@ -203,7 +203,7 @@ let currentExercise = null;
|
|||
let editingWorkoutId = null; // non-null when editing a saved workout
|
||||
let lastSetAt = null; // ms-epoch of most recent addSet, or null
|
||||
let restTimerInterval = null;
|
||||
let settings = { rest_timer: true };
|
||||
let settings = { rest_timer: true, weight_sign_button: true };
|
||||
|
||||
function settingEnabled(key, def = true) {
|
||||
const v = settings[key];
|
||||
|
|
@ -922,7 +922,7 @@ async function loadSettings() {
|
|||
if (!userId) return;
|
||||
try {
|
||||
const data = await api("GET", "/settings");
|
||||
settings = { rest_timer: true, ...(data.settings || {}) };
|
||||
settings = { rest_timer: true, weight_sign_button: true, ...(data.settings || {}) };
|
||||
applySettingsToUI();
|
||||
updateRestTimer();
|
||||
} catch (e) {
|
||||
|
|
@ -930,15 +930,24 @@ async function loadSettings() {
|
|||
}
|
||||
}
|
||||
|
||||
function applyWeightSignVisibility() {
|
||||
if (!btnWeightSign) return;
|
||||
btnWeightSign.classList.toggle("hidden", !settingEnabled("weight_sign_button"));
|
||||
}
|
||||
|
||||
function applySettingsToUI() {
|
||||
const restToggle = document.getElementById("setting-rest-timer");
|
||||
if (restToggle) restToggle.checked = settingEnabled("rest_timer");
|
||||
const signToggle = document.getElementById("setting-weight-sign");
|
||||
if (signToggle) signToggle.checked = settingEnabled("weight_sign_button");
|
||||
applyWeightSignVisibility();
|
||||
}
|
||||
|
||||
async function saveSetting(key, value) {
|
||||
// Optimistic: update locally first, then sync.
|
||||
settings[key] = value;
|
||||
updateRestTimer();
|
||||
applyWeightSignVisibility();
|
||||
try {
|
||||
await api("PUT", "/settings", { [key]: value });
|
||||
} catch (e) {
|
||||
|
|
@ -951,6 +960,10 @@ document.getElementById("setting-rest-timer")?.addEventListener("change", (e) =>
|
|||
saveSetting("rest_timer", e.target.checked);
|
||||
});
|
||||
|
||||
document.getElementById("setting-weight-sign")?.addEventListener("change", (e) => {
|
||||
saveSetting("weight_sign_button", e.target.checked);
|
||||
});
|
||||
|
||||
// ── Version badge ───────────────────────────────────────────────
|
||||
async function loadVersion() {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -105,6 +105,15 @@
|
|||
<input type="checkbox" id="setting-rest-timer" class="settings-toggle" checked />
|
||||
</label>
|
||||
</div>
|
||||
<div class="card">
|
||||
<label class="settings-row">
|
||||
<div class="settings-row-label">
|
||||
<div class="settings-row-title">Negative weight button</div>
|
||||
<div class="settings-row-hint">Show the ± sign-flip button next to the weight input (useful for assisted bodyweight exercises).</div>
|
||||
</div>
|
||||
<input type="checkbox" id="setting-weight-sign" class="settings-toggle" checked />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer id="app-footer">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue