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
* Ensure that standard slots are repainted when any component changes
* Reload page if Safari throws a security error
#2.2.14
* Ensure that jitter is shown correctly when the result of a special effect

View File

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

View File

@@ -76,7 +76,16 @@ Router.go = function(path, state) {
if (isStandAlone()) {
Persist.setState(ctx);
}
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;
};
@@ -99,7 +108,16 @@ Router.replace = function(path, state, dispatch) {
if (isStandAlone()) {
Persist.setState(ctx);
}
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;
};

View File

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

View File

@@ -39,6 +39,14 @@ export default class Page extends React.Component {
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);
}
}
/**