2021-06-15 12:36:23 +02:00
|
|
|
import axios from 'axios';
|
|
|
|
import { store } from '../store/store';
|
|
|
|
import { createNotification } from '../store/actions';
|
|
|
|
|
|
|
|
export const checkVersion = async (isForced: boolean = false) => {
|
|
|
|
try {
|
2021-10-05 16:31:56 +02:00
|
|
|
const res = await axios.get<string>(
|
|
|
|
'https://raw.githubusercontent.com/pawelmalak/flame/master/client/.env'
|
|
|
|
);
|
2021-06-15 12:36:23 +02:00
|
|
|
|
|
|
|
const githubVersion = res.data
|
|
|
|
.split('\n')
|
2021-10-05 16:31:56 +02:00
|
|
|
.map((pair) => pair.split('='))[0][1];
|
2021-06-15 12:36:23 +02:00
|
|
|
|
|
|
|
if (githubVersion !== process.env.REACT_APP_VERSION) {
|
2021-10-05 16:31:56 +02:00
|
|
|
store.dispatch<any>(
|
|
|
|
createNotification({
|
|
|
|
title: 'Info',
|
|
|
|
message: 'New version is available!',
|
|
|
|
url: 'https://github.com/pawelmalak/flame/blob/master/CHANGELOG.md',
|
|
|
|
})
|
|
|
|
);
|
2021-06-15 12:36:23 +02:00
|
|
|
} else if (isForced) {
|
2021-10-05 16:31:56 +02:00
|
|
|
store.dispatch<any>(
|
|
|
|
createNotification({
|
|
|
|
title: 'Info',
|
|
|
|
message: 'You are using the latest version!',
|
|
|
|
})
|
|
|
|
);
|
2021-06-15 12:36:23 +02:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
2021-10-05 16:31:56 +02:00
|
|
|
};
|