Skip to content

Commit

Permalink
[errorview] persist the overflow url so that refresh works
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Apr 6, 2016
1 parent 8b4ebf5 commit e308db9
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/ui/public/error_url_overflow/error_url_overflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ import uiModules from 'ui/modules';
import './error_url_overflow.less';
import template from './error_url_overflow.html';

const key = 'error/url-overflow/url';
const store = window.sessionStorage || {
getItem() {},
setItem() {},
removeItem() {},
};

export function OverflowedUrlStoreProvider() {
let value;
let value = store.getItem(key);

return {
set(v) { value = v; },
get() { return value; },
clear() { value = null; }
set(v) {
value = v;
store.setItem(key, value);
},
get() {
return value;
},
clear() {
value = null;
store.removeItem(key);
}
};
}

Expand All @@ -21,14 +37,15 @@ uiRoutes
constructor(Private, config, $scope) {
const overflowedUrlStore = Private(OverflowedUrlStoreProvider);
this.url = overflowedUrlStore.get();
overflowedUrlStore.clear();

if (!this.url) {
window.location.hash = '#/';
return;
}

this.limit = config.get('url:limit');

$scope.$on('$destroy', () => overflowedUrlStore.clear());
}
}
});

0 comments on commit e308db9

Please sign in to comment.