1
0

scaffolding for a timestamp

This commit is contained in:
2024-08-14 19:30:42 +10:00
parent ad25774ef9
commit 78bbe26fa8
+9 -2
View File
@@ -49,12 +49,14 @@ const WeatherMap = ({ zoom, dark }) => {
const [currentMapTimestampIdx, setCurrentMapTimestampIdx] = useState(0);
const MAP_TIMESTAMP_REFRESH_FREQUENCY = 1000 * 60 * 10; //update every 10 minutes
const MAP_CYCLE_RATE = 1000; //ms
const MAP_CYCLE_RATE = 500; //ms
const getMapApiKeyCallback = useCallback(() => getMapApiKey(), [
getMapApiKey,
]);
//const delay = ms => new Promise(res => setTimeout(res, ms));
useEffect(() => {
getMapApiKeyCallback().catch((err) => {
console.log("err!", err);
@@ -101,16 +103,21 @@ const WeatherMap = ({ zoom, dark }) => {
useEffect(() => {
if (mapTimestamps) {
if (animateWeatherMap) {
let cycleRate = MAP_CYCLE_RATE;
const interval = setInterval(() => {
let nextIdx;
//let d = new Date(mapTimestamps[currentMapTimestampIdx]*1000);
//console.log(d.toTimeString());
if (currentMapTimestampIdx + 1 >= mapTimestamps.length) {
nextIdx = 0;
cycleRate = 5000;
} else {
nextIdx = currentMapTimestampIdx + 1;
}
setCurrentMapTimestampIdx(nextIdx);
}, MAP_CYCLE_RATE);
}, cycleRate);
return () => {
//console.log(cycleRate);
clearInterval(interval);
};
} else {