feat(set-groups): добавление объединений упражнений в сеты с выводом по раундам
Новые модули logic/group.js, modals/group-modal.js, render/circuit-card.js. Тренировка получает поле setGroups, состояние нормализует отсутствующие поля в loadState, удаление упражнения распускает неполные сеты.
This commit is contained in:
@@ -50,12 +50,25 @@ export function loadState() {
|
||||
if (!state.metricTypes) state.metricTypes = [];
|
||||
if (!state.clients) state.clients = [];
|
||||
if (!state.mode) state.mode = 'personal';
|
||||
normalizeWorkouts();
|
||||
} catch (e) {
|
||||
console.error('Failed to load state', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Допиваем поля, которых может не быть в сохранении старой версии
|
||||
function normalizeWorkouts() {
|
||||
for (const w of state.workouts || []) {
|
||||
if (!Array.isArray(w.exercises)) w.exercises = [];
|
||||
if (!Array.isArray(w.cardio)) w.cardio = [];
|
||||
if (!Array.isArray(w.setGroups)) w.setGroups = [];
|
||||
for (const ex of w.exercises) {
|
||||
if (!Array.isArray(ex.sets)) ex.sets = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function saveState() {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
||||
updateSyncStatus();
|
||||
|
||||
Reference in New Issue
Block a user