check git hash to reset page
All checks were successful
CI / build (push) Successful in 34s
CI / lint (push) Successful in 8s
CI / create-and-publish-docker-image (push) Successful in 13s

This commit is contained in:
2025-09-03 15:15:08 +02:00
parent 5cb323a1d2
commit f7c97169d0
5 changed files with 80 additions and 73 deletions

View File

@@ -16,6 +16,28 @@ import Weather from "@/components/Weather/Weather";
import style from "./style.module.css";
export default function Dashboard() {
// '/git-hash.html' contains the current git commit hash, check it every 10 seconds and reload if it isn't the same
const [gitHash, setGitHash] = useState("");
useEffect(() => {
const interval = setInterval(async () => {
const response = await fetch("/git-hash.html");
const text = await response.text();
const newHash = text.trim();
console.log("Fetched git hash:", newHash);
if (gitHash === "") {
setGitHash(newHash);
}
if (gitHash !== "" && newHash !== gitHash) {
setGitHash(newHash);
window.location.reload();
}
}, 10000);
return () => clearInterval(interval);
}, [gitHash]);
const schemes = [style.day, style.evening, style.night];
const [schemeIndex, setSchemeIndex] = useState(0);
const scheme = schemes[schemeIndex];