Fixed runaway price update

This commit is contained in:
Gunnar Skjold 2023-10-10 21:08:37 +02:00
parent 3af19c9b15
commit 88ddc6ea15
2 changed files with 16 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -121,13 +121,17 @@ export async function shiftPrices() {
});
if(fetchUpdate) {
getPrices();
} else {
let date = new Date();
priceShiftTimeout = setTimeout(shiftPrices, ((60-date.getMinutes())*60000))
}
let date = new Date();
priceShiftTimeout = setTimeout(shiftPrices, ((60-date.getMinutes())*60000))
}
export async function getPrices() {
if(priceShiftTimeout) {
clearTimeout(priceShiftTimeout);
priceShiftTimeout = 0;
}
const response = await fetchWithTimeout("/energyprice.json");
prices = (await response.json())
pricesStore.set(prices);