Commit f847c346 authored by Matija Obreza's avatar Matija Obreza
Browse files

AppVersionCheck must reschedule also on server error


Signed-off-by: Matija Obreza's avatarMatija Obreza <matija.obreza@croptrust.org>
parent 06583179
......@@ -17,19 +17,23 @@ const getServerInfo = (info: ApiInfo) => ({
payload: { info },
});
const delay = 5 * 60 * 1000;
const delay = 5 * 60 * 1000; // 5 min
export const checkSoftwareVersion = () => (dispatch, getState) => {
return AppVersionService.getSoftwareVersion()
.then((softwareVersion) => {
// @ts-ignore
const currentSoftVersion = window.softwareCommit;
const currentSoftVersion: string = window.softwareCommit;
if (currentSoftVersion !== softwareVersion) {
dispatch(showSnackbar('New version is available', PageReloadButton));
}
setTimeout(() => dispatch(checkSoftwareVersion()), delay);
}).catch((err) => {
console.log('Version check failed, retrying in 10s');
setTimeout(() => dispatch(checkSoftwareVersion()), 10 * 1000);
});
};
......@@ -4,7 +4,7 @@ const SOFTWARE_VERSION_URL = '/COMMITHASH';
export default class AppVersionService {
public static getSoftwareVersion = () => {
public static getSoftwareVersion = (): Promise<string> => {
const virtualPath = document.baseURI.replace(/^(https?:\/\/[^\/]+)?(.*)\/$/, '$2');
const timestamp = new Date().getTime();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment