Add an update link for android

This commit is contained in:
Eric van der Vlist 2023-03-09 21:51:52 +01:00
parent 677ac02835
commit 06daffbd1c
2 changed files with 35 additions and 7 deletions

View File

@ -0,0 +1,3 @@
.mobile {
padding-top: 20px;
}

View File

@ -1,5 +1,7 @@
import { Alert } from '@suid/material';
import { Alert, Button } from '@suid/material';
import { Component, createSignal, onCleanup, Show } from 'solid-js';
import { Browser } from '@capacitor/browser';
import style from './Updater.module.css';
interface Props {}
@ -21,18 +23,41 @@ const Updater: Component<Props> = (props) => {
setUpdateNeeded(latestRelease !== currentRelease);
};
const intervalId = setInterval(checkUpdate, 30 * 1000);
const intervalId = setInterval(checkUpdate, 60 * 60 * 1000);
checkUpdate();
onCleanup(() => {
clearInterval(intervalId);
});
return (
<>
<Show when={updateNeeded()}>
<Show when={window.Capacitor.platform === 'android'}>
<div class={style.mobile}>
<Alert severity='warning'>
The app needs to be updated
<Button
variant='outlined'
onclick={() => {
Browser.open({
url: 'https://dyomedea.app/assets/release/dyomedea.apk',
});
}}
>
Update
</Button>
</Alert>
</div>
</Show>
<Show when={window.Capacitor.platform === 'web'}>
<Alert severity='warning' class={style.mobile}>
Please reload this page to update the application.
</Alert>
</Show>
</Show>
</>
);
};