[kbnUrl] clarify the purpose _shouldAutoReload

This commit is contained in:
spalger 2016-10-24 16:45:52 -07:00
parent a7304ec425
commit fbfbae3926

View file

@ -165,7 +165,7 @@ function KbnUrlProvider($injector, $location, $rootScope, $parse, Private) {
if ($injector.has('$route')) {
const $route = $injector.get('$route');
if (self._shouldAutoReload(next, prev, $route)) {
if (self._shouldForceReload(next, prev, $route)) {
const appState = Private(AppStateProvider).getAppState();
if (appState) appState.destroy();
@ -180,21 +180,21 @@ function KbnUrlProvider($injector, $location, $rootScope, $parse, Private) {
}
};
self._shouldAutoReload = function (next, prev, $route) {
// determine if the router will automatically reload the route
self._shouldForceReload = function (next, prev, $route) {
if (reloading) return false;
let route = $route.current && $route.current.$$route;
if (!route) return false;
// for the purposes of determining wether there will be a reload,
// '' and '/' are equal
// for the purposes of determining whether the router will
// automatically be reloading, '' and '/' are equal
const nextPath = next.path || '/';
const prevPath = prev.path || '/';
if (nextPath !== prevPath) return false;
let reloadOnSearch = route.reloadOnSearch;
let searchSame = _.isEqual(next.search, prev.search);
return (reloadOnSearch && searchSame) || !reloadOnSearch;
};
}