format and request permission to store data

fixes people losing builds
This commit is contained in:
willyb321
2018-09-15 08:54:06 +10:00
parent 00f4889c93
commit 469f7a0a48

View File

@@ -134,9 +134,9 @@ export default class Coriolis extends React.Component {
console && console.error && console.error(arguments); // eslint-disable-line no-console console && console.error && console.error(arguments); // eslint-disable-line no-console
if (errObj) { if (errObj) {
if (errObj instanceof Error) { if (errObj instanceof Error) {
bugsnagClient.notify(errObj) // eslint-disable-line bugsnagClient.notify(errObj); // eslint-disable-line
} else if (errObj instanceof String) { } else if (errObj instanceof String) {
bugsnagClient.notify(msg, errObj) // eslint-disable-line bugsnagClient.notify(msg, errObj); // eslint-disable-line
} }
} }
this.setState({ this.setState({
@@ -180,13 +180,13 @@ export default class Coriolis extends React.Component {
case 72: // 'h' case 72: // 'h'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + h if (e.ctrlKey || e.metaKey) { // CTRL/CMD + h
e.preventDefault(); e.preventDefault();
this._showModal(<ModalHelp />); this._showModal(<ModalHelp/>);
} }
break; break;
case 73: // 'i' case 73: // 'i'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + i if (e.ctrlKey || e.metaKey) { // CTRL/CMD + i
e.preventDefault(); e.preventDefault();
this._showModal(<ModalImport />); this._showModal(<ModalImport/>);
} }
break; break;
case 79: // 'o' case 79: // 'o'
@@ -208,7 +208,7 @@ export default class Coriolis extends React.Component {
* @param {React.Component} content Modal Content * @param {React.Component} content Modal Content
*/ */
_showModal(content) { _showModal(content) {
let modal = <div className='modal-bg' onClick={(e) => this._hideModal() }>{content}</div>; let modal = <div className='modal-bg' onClick={(e) => this._hideModal()}>{content}</div>;
this.setState({ modal }); this.setState({ modal });
} }
@@ -286,7 +286,7 @@ export default class Coriolis extends React.Component {
return this.emitter.addListener('windowResize', listener); return this.emitter.addListener('windowResize', listener);
} }
/** /**
* Add a listener to global commands such as save, * Add a listener to global commands such as save,
* @param {Function} listener Listener callback * @param {Function} listener Listener callback
* @return {Object} Subscription token * @return {Object} Subscription token
@@ -323,6 +323,16 @@ export default class Coriolis extends React.Component {
componentWillMount() { componentWillMount() {
// Listen for appcache updated event, present refresh to update view // Listen for appcache updated event, present refresh to update view
// Check that service workers are registered // Check that service workers are registered
if (navigator.storage && navigator.storage.persist) {
window.addEventListener('load', () => {
navigator.storage.persist().then(granted => {
if (granted)
console.log('Storage will not be cleared except by explicit user action');
else
console.log('Storage may be cleared by the UA under storage pressure.');
});
}
}
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
window.addEventListener('load', () => { window.addEventListener('load', () => {
// Your service-worker.js *must* be located at the top-level directory relative to your site. // Your service-worker.js *must* be located at the top-level directory relative to your site.
@@ -383,16 +393,22 @@ export default class Coriolis extends React.Component {
render() { render() {
let currentMenu = this.state.currentMenu; let currentMenu = this.state.currentMenu;
return <div style={{ minHeight: '100%' }} onClick={this._closeMenu} className={ this.state.noTouch ? 'no-touch' : null }> return <div style={{ minHeight: '100%' }} onClick={this._closeMenu}
<Header appCacheUpdate={this.state.appCacheUpdate} currentMenu={currentMenu} /> className={this.state.noTouch ? 'no-touch' : null}>
{ this.state.error ? this.state.error : this.state.page ? React.createElement(this.state.page, { currentMenu }) : <NotFoundPage/> } <Header appCacheUpdate={this.state.appCacheUpdate} currentMenu={currentMenu}/>
{ this.state.modal } {this.state.error ? this.state.error : this.state.page ? React.createElement(this.state.page, { currentMenu }) :
{ this.state.tooltip } <NotFoundPage/>}
{this.state.modal}
{this.state.tooltip}
<footer> <footer>
<div className="right cap"> <div className="right cap">
<a href="https://github.com/EDCD/coriolis" target="_blank" title="Coriolis Github Project">{window.CORIOLIS_VERSION} - {window.CORIOLIS_DATE}</a> <a href="https://github.com/EDCD/coriolis" target="_blank"
title="Coriolis Github Project">{window.CORIOLIS_VERSION} - {window.CORIOLIS_DATE}</a>
<br/> <br/>
<a href={'https://github.com/EDCD/coriolis/compare/edcd:develop@{' + window.CORIOLIS_DATE + '}...edcd:develop'} target="_blank" title={'Coriolis Commits since' + window.CORIOLIS_DATE}>Commits since last release ({window.CORIOLIS_DATE})</a> <a
href={'https://github.com/EDCD/coriolis/compare/edcd:develop@{' + window.CORIOLIS_DATE + '}...edcd:develop'}
target="_blank" title={'Coriolis Commits since' + window.CORIOLIS_DATE}>Commits since last release
({window.CORIOLIS_DATE})</a>
</div> </div>
</footer> </footer>
</div>; </div>;