diff --git a/Hydroflux/app/src/main/assets/js/modules/dashboard.js b/Hydroflux/app/src/main/assets/js/modules/dashboard.js index c188467..24362fd 100644 --- a/Hydroflux/app/src/main/assets/js/modules/dashboard.js +++ b/Hydroflux/app/src/main/assets/js/modules/dashboard.js @@ -10,6 +10,33 @@ export class Dashboard { render() { if (!this.container) return; + // --- VERSION MIGRATION LOGIC --- + const APP_VERSION = '5.0'; + const currentVersion = localStorage.getItem('hydroflux_version'); + + if (currentVersion !== APP_VERSION) { + console.log(`Migrating from ${currentVersion} to ${APP_VERSION}`); + + // Force reset of settings for V5 to ensure new defaults (3.0L goal) are applied + // But try to keep history if possible + const oldHistory = localStorage.getItem('hydroflux_water_history'); + + // Clear Data + localStorage.removeItem('hydroflux_data'); + // We don't clear 'hydroflux_health_data' as that comes from sync, but maybe good to refresh it + + // Set Defaults + localStorage.setItem('hydroflux_data', JSON.stringify({ current: 0, goal: 3.0 })); // Force 3.0L Goal + + if (oldHistory) { + localStorage.setItem('hydroflux_water_history', oldHistory); + } + + localStorage.setItem('hydroflux_version', APP_VERSION); + localStorage.setItem('hydroflux_drink_size', '250'); // Default drink size + } + // ------------------------------- + // Data Retrieval (Keeping persistence) const waterData = JSON.parse(localStorage.getItem('hydroflux_data') || '{"current":0,"goal":3.0}'); @@ -53,7 +80,10 @@ export class Dashboard {