mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-11-13 22:05:15 +00:00
backend test
This commit is contained in:
@@ -2,23 +2,6 @@ import { useCallback, useEffect, useState } from "react";
|
||||
import { useHealth } from "src/hooks";
|
||||
import { T } from "src/locale";
|
||||
|
||||
const compareVersions = (current: string, latest: string): boolean => {
|
||||
const cleanCurrent = current.replace(/^v/, "");
|
||||
const cleanLatest = latest.replace(/^v/, "");
|
||||
|
||||
const currentParts = cleanCurrent.split(".").map(Number);
|
||||
const latestParts = cleanLatest.split(".").map(Number);
|
||||
|
||||
for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
|
||||
const curr = currentParts[i] || 0;
|
||||
const lat = latestParts[i] || 0;
|
||||
|
||||
if (lat > curr) return true;
|
||||
if (lat < curr) return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export function SiteFooter() {
|
||||
const health = useHealth();
|
||||
const [latestVersion, setLatestVersion] = useState<string | null>(null);
|
||||
@@ -35,18 +18,11 @@ export function SiteFooter() {
|
||||
useEffect(() => {
|
||||
const checkForUpdates = async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
"https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest"
|
||||
);
|
||||
const response = await fetch("/api/version/check");
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const latest = data.tag_name;
|
||||
setLatestVersion(latest);
|
||||
|
||||
const currentVersion = getVersion();
|
||||
if (currentVersion && compareVersions(currentVersion, latest)) {
|
||||
setIsNewVersionAvailable(true);
|
||||
}
|
||||
setLatestVersion(data.latest);
|
||||
setIsNewVersionAvailable(data.updateAvailable);
|
||||
}
|
||||
} catch (error) {
|
||||
console.debug("Could not check for updates:", error);
|
||||
@@ -56,7 +32,7 @@ export function SiteFooter() {
|
||||
if (health.data) {
|
||||
checkForUpdates();
|
||||
}
|
||||
}, [health.data, getVersion]);
|
||||
}, [health.data]);
|
||||
|
||||
return (
|
||||
<footer className="footer d-print-none py-3">
|
||||
|
||||
Reference in New Issue
Block a user