Fix hardcoded 1.2.4 values - make frontend load current version from API on mount and update User-Agent dynamically

This commit is contained in:
Muhammad Ibrahim
2025-09-20 14:49:05 +01:00
parent d687ec4e45
commit 9a3827dced
2 changed files with 31 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ const Settings = () => {
// Version checking state
const [versionInfo, setVersionInfo] = useState({
currentVersion: '1.2.4',
currentVersion: null, // Will be loaded from API
latestVersion: null,
isUpdateAvailable: false,
checking: false,
@@ -153,6 +153,24 @@ const Settings = () => {
console.log('Agent versions error:', agentVersionsError);
}, [agentVersions, agentVersionsLoading, agentVersionsError]);
// Load current version on component mount
useEffect(() => {
const loadCurrentVersion = async () => {
try {
const response = await versionAPI.getCurrent();
const data = response.data;
setVersionInfo(prev => ({
...prev,
currentVersion: data.version
}));
} catch (error) {
console.error('Error loading current version:', error);
}
};
loadCurrentVersion();
}, []);
const createAgentVersionMutation = useMutation({
mutationFn: (data) => agentVersionAPI.create(data).then(res => res.data),
onSuccess: () => {