diff --git a/package.json b/package.json index eed4ed4..58d9ec0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "daithi-dashboard", - "version": "2.10.0", + "version": "2.10.1", "private": true, "dependencies": { "@emotion/react": "^11.11.3", diff --git a/public/manifest.json b/public/manifest.json index e450837..2f4bc30 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -18,7 +18,7 @@ "sizes": "512x512" } ], - "version": "2.10.0", + "version": "2.10.1", "start_url": ".", "display": "standalone", "theme_color": "#000000", diff --git a/src/components/PriceChart.tsx b/src/components/PriceChart.tsx index 8b9a7df..3bfde17 100644 --- a/src/components/PriceChart.tsx +++ b/src/components/PriceChart.tsx @@ -46,7 +46,7 @@ const PriceChart: React.FC = ({ useEffect(() => { if (!showCurrentPrice || prices.length <= 1) return - // Function to be executed every minute + const updateData = () => { if (!showCurrentPrice || prices.length <= 1) return @@ -71,8 +71,8 @@ const PriceChart: React.FC = ({ // Run the function on component load updateData() - // Set the interval to run the function every minute - const intervalId = setInterval(updateData, 10 * 60 * 1000) + // Set the interval to run the function every 5 minutes + const intervalId = setInterval(updateData, 5 * 60 * 1000) // Cleanup function to clear the interval when the component is unmounted return () => { diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index ae64de2..ad82892 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from "react" +import React, { useCallback, useEffect, useState } from "react" import Box from "@mui/material/Box" import Typography from "@mui/material/Typography" import Paper from "@mui/material/Paper" @@ -76,5 +76,19 @@ const DashboardContent: React.FC = () => { } export default function Dashboard() { + // At the start of every hour we want to refetch the data + const { now } = useDateTime() + useEffect(() => { + const intervalId = setInterval(() => { + if (now().minute === 0) { + window.location.reload() + } + }, 35 * 1000) + + return () => { + clearInterval(intervalId) + } + }, [now]) + return }