fix(inspectedApp): handle refresh better

master
Brian Ford 10 years ago
parent 287074b73e
commit fce0052322

@ -80,11 +80,17 @@ function inspectedAppService($rootScope, $q) {
if (hint.event === 'scope:new') { if (hint.event === 'scope:new') {
addNewScope(hint); addNewScope(hint);
} else if (hint.id && scopes[hint.id]) { } else if (hint.id && scopes[hint.id]) {
if (hint.event === 'model:change') { var scope = scopes[hint.id];
scopes[hint.id].models[hint.path] = (typeof hint.value === 'undefined') ? if (hint.event === 'scope:destroy') {
if (scope.parent) {
scope.parent.children.splice(scope.parent.children.indexOf(child), 1);
}
delete scopes[hint.id];
} else if (hint.event === 'model:change') {
scope.models[hint.path] = (typeof hint.value === 'undefined') ?
undefined : JSON.parse(hint.value); undefined : JSON.parse(hint.value);
} else if (hint.event === 'scope:link') { } else if (hint.event === 'scope:link') {
scopes[hint.id].descriptor = hint.descriptor; scope.descriptor = hint.descriptor;
} }
} }
$rootScope.$broadcast(hint.event, hint); $rootScope.$broadcast(hint.event, hint);
@ -92,6 +98,7 @@ function inspectedAppService($rootScope, $q) {
} }
function onRefreshMessage() { function onRefreshMessage() {
clear(scopes);
hints.length = 0; hints.length = 0;
} }
@ -106,4 +113,10 @@ function inspectedAppService($rootScope, $q) {
} }
} }
function clear (obj) {
Object.keys(obj).forEach(function (key) {
delete obj[key];
});
}
} }