manager: double check widget's existence before returning a list and prune (since linkId/id/address can change, removing the widgets can leave old routes leading nowhere)

This commit is contained in:
jean-emmanuel 2016-12-08 09:56:19 +01:00
parent 7121c644db
commit 0fe1ce197f

View file

@ -113,15 +113,20 @@ WidgetManager.prototype.purge = function() {
WidgetManager.prototype.getWidgetBy = function(key, dict) {
var w = [],
h1
var widgets = [],
h1, w
for (h2 in dict[key]) {
h1 = dict[key][h2]
w.push(this.widgets[[h1,h2].join('/')])
w = this.widgets[[h1,h2].join('/')]
if (!w) {
delete dict[key][h2]
} else {
widgets.push(this.widgets[[h1,h2].join('/')])
}
}
return w
return widgets
}