[TASK] Remove instead of add filter twice

This commit is contained in:
Xaver Maierhofer 2017-03-29 00:45:52 +02:00 committed by Geno
parent b9252c864f
commit 6a3986e588
2 changed files with 21 additions and 5 deletions

View File

@ -54,10 +54,21 @@ define(['filters/nodefilter'], function (NodeFilter) {
} }
function addFilter(d) { function addFilter(d) {
filters.push(d); var newItem = true;
notifyObservers();
d.setRefresh(refresh); filters.forEach(function (f) {
refresh(); if (f.getKey && f.getKey() === d.getKey()) {
removeFilter(f);
newItem = false;
}
});
if (newItem) {
filters.push(d);
notifyObservers();
d.setRefresh(refresh);
refresh();
}
} }
function removeFilter(d) { function removeFilter(d) {

View File

@ -49,10 +49,15 @@ define(['helper'], function (helper) {
}; };
} }
function getKey() {
return value.concat(name);
}
return { return {
run: run, run: run,
setRefresh: setRefresh, setRefresh: setRefresh,
render: render render: render,
getKey: getKey
}; };
}; };
}); });