2022-08-31 13:30:20 +00:00
|
|
|
import { IonApp, setupIonicReact } from '@ionic/react';
|
2022-09-24 08:31:40 +00:00
|
|
|
|
2022-09-11 22:45:40 +00:00
|
|
|
import store from './store/index';
|
|
|
|
import { Provider } from 'react-redux';
|
2022-09-24 15:08:53 +00:00
|
|
|
import { Suspense } from 'react';
|
2022-09-26 19:48:46 +00:00
|
|
|
import { PouchDB } from 'react-pouchdb';
|
2022-08-31 12:35:20 +00:00
|
|
|
|
|
|
|
/* Core CSS required for Ionic components to work properly */
|
|
|
|
import '@ionic/react/css/core.css';
|
|
|
|
|
|
|
|
/* Basic CSS for apps built with Ionic */
|
|
|
|
import '@ionic/react/css/normalize.css';
|
|
|
|
import '@ionic/react/css/structure.css';
|
|
|
|
import '@ionic/react/css/typography.css';
|
|
|
|
|
|
|
|
/* Optional CSS utils that can be commented out */
|
|
|
|
import '@ionic/react/css/padding.css';
|
|
|
|
import '@ionic/react/css/float-elements.css';
|
|
|
|
import '@ionic/react/css/text-alignment.css';
|
|
|
|
import '@ionic/react/css/text-transformation.css';
|
|
|
|
import '@ionic/react/css/flex-utils.css';
|
|
|
|
import '@ionic/react/css/display.css';
|
|
|
|
|
|
|
|
/* Theme variables */
|
|
|
|
import './theme/variables.css';
|
|
|
|
|
2022-09-14 08:08:14 +00:00
|
|
|
import Map from './components/map/map';
|
2022-08-31 20:03:27 +00:00
|
|
|
|
2022-08-31 12:35:20 +00:00
|
|
|
setupIonicReact();
|
|
|
|
|
2022-10-11 14:12:45 +00:00
|
|
|
// See https://stackoverflow.com/questions/71538643/property-wakelock-does-not-exist-on-type-navigator
|
|
|
|
const requestWakeLock = async () => {
|
|
|
|
const anyNav: any = navigator;
|
|
|
|
if ('wakeLock' in navigator) {
|
|
|
|
try {
|
|
|
|
const wakeLock = await anyNav['wakeLock'].request('screen');
|
|
|
|
} catch (err: any) {
|
|
|
|
// The wake lock request fails - usually system-related, such as low battery.
|
|
|
|
console.log(`Wake lock request failed: ${err.name}, ${err.message}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log('No wake lock support here...');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleVisibilityChange = () => {
|
|
|
|
if (document.hidden) {
|
|
|
|
console.log('Application hidden');
|
|
|
|
} else {
|
|
|
|
console.log('Application visible');
|
|
|
|
requestWakeLock();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
|
|
|
document.addEventListener('visibilitychange', handleVisibilityChange, false);
|
|
|
|
requestWakeLock();
|
|
|
|
|
2022-09-24 15:08:53 +00:00
|
|
|
const App: React.FC = () => {
|
|
|
|
return (
|
|
|
|
<IonApp>
|
|
|
|
<Provider store={store}>
|
2022-10-11 14:12:45 +00:00
|
|
|
<PouchDB name='dyomedea' auto_compaction={true} revs_limit={10}>
|
2022-09-24 15:08:53 +00:00
|
|
|
<Suspense fallback='loading...'>
|
|
|
|
<Map />
|
|
|
|
</Suspense>
|
|
|
|
</PouchDB>
|
|
|
|
</Provider>
|
|
|
|
</IonApp>
|
|
|
|
);
|
|
|
|
};
|
2022-08-31 12:35:20 +00:00
|
|
|
|
|
|
|
export default App;
|