check git hash to reset page
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user