diff --git a/Hydroflux/app/src/main/assets/js/modules/views/SleepView.js b/Hydroflux/app/src/main/assets/js/modules/views/SleepView.js index 98f2996..6b83e51 100644 --- a/Hydroflux/app/src/main/assets/js/modules/views/SleepView.js +++ b/Hydroflux/app/src/main/assets/js/modules/views/SleepView.js @@ -40,12 +40,16 @@ export class SleepView {
+
REM - ${formatTime(remHours)} +
+ ${formatTime(remHours)} + (25%) +
@@ -56,7 +60,10 @@ export class SleepView {
Deep Sleep - ${formatTime(deepHours)} +
+ ${formatTime(deepHours)} + (20%) +
@@ -67,7 +74,10 @@ export class SleepView {
Light Sleep - ${formatTime(lightHours)} +
+ ${formatTime(lightHours)} + (55%) +
diff --git a/Hydroflux/app/src/main/assets/js/modules/views/WaterView.js b/Hydroflux/app/src/main/assets/js/modules/views/WaterView.js index f061479..f3581ab 100644 --- a/Hydroflux/app/src/main/assets/js/modules/views/WaterView.js +++ b/Hydroflux/app/src/main/assets/js/modules/views/WaterView.js @@ -179,14 +179,40 @@ export class WaterView { }); this.container.querySelector('#removeWater').addEventListener('click', () => { - // Removing doesn't add to history, usually just undoes - const data = JSON.parse(localStorage.getItem('hydroflux_data') || '{"current":0,"goal":3.0}'); - const drinkSize = parseInt(localStorage.getItem('hydroflux_drink_size') || '250'); - data.current = Math.max(data.current - (drinkSize / 1000), 0); - localStorage.setItem('hydroflux_data', JSON.stringify(data)); + // Find last entry for today + const todayStart = new Date(); + todayStart.setHours(0, 0, 0, 0); + const todayTimestamp = todayStart.getTime(); + + // Filter history for today + const todaysEntries = this.history.filter(h => h.timestamp >= todayTimestamp); + + if (todaysEntries.length > 0) { + // Get the last added entry + const lastEntry = todaysEntries[todaysEntries.length - 1]; + + // Remove it from the main history array (find index) + const index = this.history.indexOf(lastEntry); + if (index > -1) { + this.history.splice(index, 1); + } + localStorage.setItem('hydroflux_water_history', JSON.stringify(this.history)); + + // Update Total + const data = JSON.parse(localStorage.getItem('hydroflux_data') || '{"current":0,"goal":3.0}'); + // Ensure we don't go below 0 + data.current = Math.max(data.current - (lastEntry.amount / 1000), 0); + localStorage.setItem('hydroflux_data', JSON.stringify(data)); + } else { + // Fallback: If no history for today, just decrement by drink size + const data = JSON.parse(localStorage.getItem('hydroflux_data') || '{"current":0,"goal":3.0}'); + const drinkSize = parseInt(localStorage.getItem('hydroflux_drink_size') || '250'); + if (data.current > 0) { + data.current = Math.max(data.current - (drinkSize / 1000), 0); + localStorage.setItem('hydroflux_data', JSON.stringify(data)); + } + } - // Optionally remove last history entry if it matches? - // For now just keep it simple this.render(); this.attachEvents(); }); diff --git a/Hydroflux/releases/HydroFlux V6.apk b/Hydroflux/releases/HydroFlux V6.apk new file mode 100644 index 0000000..a76a20b Binary files /dev/null and b/Hydroflux/releases/HydroFlux V6.apk differ