refactor: get server version via backend method

Avoid touching the server directly. Maintains consistency with existing
workflow and centralizes changes in the event that, for example, auth
requirements change for this route.
This commit is contained in:
Arthur E. Jones 2022-07-11 12:42:45 -05:00 committed by James Long
parent 37ca3c005a
commit 3290e73978

View file

@ -477,17 +477,12 @@ function Version() {
let [version, setVersion] = useState('');
useEffect(async () => {
const url = await send('get-server-url');
if (!url || url.indexOf('not-configured') !== -1) return;
const { error, version } = await send('get-server-version');
try {
const res = await fetch(url + '/info');
if (!res.ok) return;
const info = await res.json();
setVersion((info && info.build.version) || '');
} catch (e) {
if (error) {
setVersion('');
} else {
setVersion(version);
}
}, []);