Checking if app needs update
This commit is contained in:
parent
7997138c5e
commit
677ac02835
|
@ -51,6 +51,7 @@ import Invitation, {
|
||||||
searchInvitationInIntent,
|
searchInvitationInIntent,
|
||||||
} from '../invitation';
|
} from '../invitation';
|
||||||
import { returnOrUpdate } from 'ol/extent';
|
import { returnOrUpdate } from 'ol/extent';
|
||||||
|
import Updater from '../updater';
|
||||||
|
|
||||||
const [getState, setState] = createSignal({
|
const [getState, setState] = createSignal({
|
||||||
lon: 0,
|
lon: 0,
|
||||||
|
@ -311,6 +312,7 @@ const Map: Component = () => {
|
||||||
//<OsmFetch map={getMap} />
|
//<OsmFetch map={getMap} />
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<div class='ol-map' ref={target}>
|
<div class='ol-map' ref={target}>
|
||||||
|
<Updater/>
|
||||||
<Invitation />
|
<Invitation />
|
||||||
<Overlays map={getMap} />
|
<Overlays map={getMap} />
|
||||||
<Note />
|
<Note />
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { Alert } from '@suid/material';
|
||||||
|
import { Component, createSignal, onCleanup, Show } from 'solid-js';
|
||||||
|
|
||||||
|
interface Props {}
|
||||||
|
|
||||||
|
const Updater: Component<Props> = (props) => {
|
||||||
|
const [updateNeeded, setUpdateNeeded] = createSignal(false);
|
||||||
|
|
||||||
|
const checkUpdate = async () => {
|
||||||
|
const response = await fetch(
|
||||||
|
'https://dyomedea.app/assets/release/dyomedea.rel',
|
||||||
|
{
|
||||||
|
mode: 'cors', // no-cors, *cors, same-origin
|
||||||
|
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
||||||
|
credentials: 'same-origin',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const latestRelease = (await response.text()).replace('\n', '');
|
||||||
|
const currentRelease = import.meta.env.VITE_GIT_COMMIT_HASH;
|
||||||
|
console.log({ caller: 'checkUpdate', currentRelease, latestRelease });
|
||||||
|
setUpdateNeeded(latestRelease !== currentRelease);
|
||||||
|
};
|
||||||
|
|
||||||
|
const intervalId = setInterval(checkUpdate, 30 * 1000);
|
||||||
|
|
||||||
|
onCleanup(() => {
|
||||||
|
clearInterval(intervalId);
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Show when={updateNeeded()}>
|
||||||
|
<Alert severity='warning'>
|
||||||
|
Please reload this page to update the application.
|
||||||
|
</Alert>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Updater;
|
|
@ -0,0 +1 @@
|
||||||
|
export { default } from './Updater';
|
Loading…
Reference in New Issue