Merge pull request 'fixed updating charts with selected time range' (#34) from fix-sleep-overview-not-updating into main
Reviewed-on: #34
This commit was merged in pull request #34.
This commit is contained in:
@@ -345,13 +345,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
document
|
||||
.getElementById("timeRangeFilter")
|
||||
.addEventListener("change", function () {
|
||||
// Save selection to localStorage
|
||||
localStorage.setItem("lastSleepTimeRange", this.value);
|
||||
loadData();
|
||||
});
|
||||
function attachTimeRangeListener() {
|
||||
const timeRangeFilter = document.getElementById("timeRangeFilter");
|
||||
if (timeRangeFilter) {
|
||||
timeRangeFilter.addEventListener("change", function () {
|
||||
// Save selection to localStorage
|
||||
localStorage.setItem("lastSleepTimeRange", this.value);
|
||||
renderCharts();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
try {
|
||||
@@ -443,6 +446,9 @@
|
||||
attachChildFilterListener();
|
||||
}
|
||||
|
||||
// Always attach time range listener after recreating the controls
|
||||
attachTimeRangeListener();
|
||||
|
||||
renderCharts();
|
||||
} catch (error) {
|
||||
console.error("Error loading data:", error);
|
||||
|
||||
Reference in New Issue
Block a user