mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Handle localstorage failure more gracefully
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
angular.module('app').directive('shipyardHeader', ['lodash','$window','$rootScope', 'Persist', 'ShipsDB', function (_, $window, $rootScope, Persist, ships) {
|
||||
angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Persist', 'ShipsDB', function (_, $rootScope, Persist, ships) {
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
@@ -20,7 +20,7 @@ angular.module('app').directive('shipyardHeader', ['lodash','$window','$rootScop
|
||||
]
|
||||
};
|
||||
|
||||
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', $window.localStorage.getItem('insurance'));
|
||||
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', Persist.getInsurance());
|
||||
$rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1? insIndex : 0];
|
||||
|
||||
// Close menus if a navigation change event occurs
|
||||
@@ -35,10 +35,10 @@ angular.module('app').directive('shipyardHeader', ['lodash','$window','$rootScop
|
||||
});
|
||||
|
||||
/**
|
||||
* Save selected insurance option in localstorage
|
||||
* Save selected insurance option
|
||||
*/
|
||||
scope.updateInsurance = function(){
|
||||
$window.localStorage.setItem('insurance', $rootScope.insurance.current.name);
|
||||
Persist.setInsurance($rootScope.insurance.current.name);
|
||||
};
|
||||
|
||||
scope.openMenu = function (e, menu) {
|
||||
|
||||
Reference in New Issue
Block a user