Reload page if Safari throws a security error

This commit is contained in:
Cmdr McDonald
2017-02-10 18:22:39 +00:00
parent 24849cee08
commit abf65ee436
5 changed files with 37 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
#2.2.15 #2.2.15
* Ensure that standard slots are repainted when any component changes * Ensure that standard slots are repainted when any component changes
* Reload page if Safari throws a security error
#2.2.14 #2.2.14
* Ensure that jitter is shown correctly when the result of a special effect * Ensure that jitter is shown correctly when the result of a special effect

View File

@@ -1,6 +1,6 @@
{ {
"name": "coriolis_shipyard", "name": "coriolis_shipyard",
"version": "2.2.14", "version": "2.2.15b",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/EDCD/coriolis" "url": "https://github.com/EDCD/coriolis"

View File

@@ -76,7 +76,16 @@ Router.go = function(path, state) {
if (isStandAlone()) { if (isStandAlone()) {
Persist.setState(ctx); Persist.setState(ctx);
} }
history.pushState(ctx.state, ctx.title, ctx.canonicalPath); try {
history.pushState(ctx.state, ctx.title, ctx.canonicalPath);
} catch (ex) {
sessionStorage.setItem('__safari_history_fix', JSON.stringify({
state: ctx.state,
title: ctx.title,
path: ctx.canonicalPath
}));
location.reload();
}
} }
return ctx; return ctx;
}; };
@@ -99,7 +108,16 @@ Router.replace = function(path, state, dispatch) {
if (isStandAlone()) { if (isStandAlone()) {
Persist.setState(ctx); Persist.setState(ctx);
} }
history.replaceState(ctx.state, ctx.title, ctx.canonicalPath); try {
history.replaceState(ctx.state, ctx.title, ctx.canonicalPath);
} catch (ex) {
sessionStorage.setItem('__safari_history_fix', JSON.stringify({
state: ctx.state,
title: ctx.title,
path: ctx.canonicalPath
}));
location.reload();
}
return ctx; return ctx;
}; };

View File

@@ -348,13 +348,13 @@ export default class OutfittingPage extends Page {
</div> </div>
</div> </div>
<ShipSummaryTable ship={ship} code={code} /> <ShipSummaryTable ship={ship} code={code || ''} />
<StandardSlotSection ship={ship} code={code} onChange={shipUpdated} currentMenu={menu} /> <StandardSlotSection ship={ship} code={code || ''} onChange={shipUpdated} currentMenu={menu} />
<InternalSlotSection ship={ship} code={iStr} onChange={shipUpdated} currentMenu={menu} /> <InternalSlotSection ship={ship} code={iStr} onChange={shipUpdated} currentMenu={menu} />
<HardpointsSlotSection ship={ship} code={hStr} onChange={shipUpdated} currentMenu={menu} /> <HardpointsSlotSection ship={ship} code={hStr || ''} onChange={shipUpdated} currentMenu={menu} />
<UtilitySlotSection ship={ship} code={hStr} onChange={shipUpdated} currentMenu={menu} /> <UtilitySlotSection ship={ship} code={hStr || ''} onChange={shipUpdated} currentMenu={menu} />
<PowerManagement ship={ship} code={code} onChange={shipUpdated} /> <PowerManagement ship={ship} code={code || ''} onChange={shipUpdated} />
<CostSection ship={ship} buildName={buildName} code={code} /> <CostSection ship={ship} buildName={buildName} code={code || ''} />
<div className='group third'> <div className='group third'>
<OffenceSummary ship={ship} code={code}/> <OffenceSummary ship={ship} code={code}/>

View File

@@ -39,6 +39,14 @@ export default class Page extends React.Component {
this[prop] = this[prop].bind(this); this[prop] = this[prop].bind(this);
} }
}); });
let fix = sessionStorage.getItem('__safari_history_fix');
sessionStorage.removeItem('__safari_history_fix');
if (fix) {
fix = JSON.parse(fix);
history.replaceState(history.state, document.title, location.href);
history.pushState(fix.state, fix.title, fix.path);
}
} }
/** /**
@@ -82,4 +90,4 @@ export default class Page extends React.Component {
return this.renderPage(); return this.renderPage();
} }
} }