mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 03:29:37 +02:00
32 lines
948 B
TypeScript
32 lines
948 B
TypeScript
import axios from 'axios';
|
|
import { useCreateNotification } from '../state/notification';
|
|
|
|
export const useCheckVersion = (isForced: boolean = false) => {
|
|
const createNotification = useCreateNotification();
|
|
return async () => {
|
|
try {
|
|
const res = await axios.get<string>(
|
|
'https://raw.githubusercontent.com/GeorgeSG/flame/master/client/.env'
|
|
);
|
|
|
|
const githubVersion = res.data
|
|
.split('\n')
|
|
.map((pair) => pair.split('='))[0][1];
|
|
|
|
if (githubVersion !== process.env.REACT_APP_VERSION) {
|
|
createNotification({
|
|
title: 'Info',
|
|
message: 'New version is available!',
|
|
url: 'https://github.com/GeorgeSG/flame/blob/master/CHANGELOG.md',
|
|
});
|
|
} else if (isForced) {
|
|
createNotification({
|
|
title: 'Info',
|
|
message: 'You are using the latest version!',
|
|
});
|
|
}
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
};
|
|
};
|