Fix plugin actions disappearing from toolbars

This commit is contained in:
Unoqwy 2021-06-15 21:04:22 +02:00
parent eab1382824
commit 7352976a74
No known key found for this signature in database
GPG Key ID: 47FF4C98BB2F232E

View File

@ -1054,6 +1054,8 @@ class Toolbar {
var scope = this;
this.children = [];
this.condition_cache = [];
// items the toolbar could not load on startup, most likely from plugins (stored as IDs)
this.postload = undefined; // default to undefined for memory footprint
if (data) {
this.id = data.id
this.narrow = !!data.narrow
@ -1099,6 +1101,10 @@ class Toolbar {
if (BARS.condition(item.condition)) {
content.append(item.getNode())
}
} else if (scope.postload) {
scope.postload.push(id);
} else {
scope.postload = [id];
}
})
}
@ -1159,6 +1165,23 @@ class Toolbar {
update() {
var scope = this;
// check if some unkown actions are now known
if (this.postload) {
var idx = 0;
while (idx < this.postload.length) {
var item = BarItems[this.postload[idx]];
if (item) {
item.pushToolbar(scope);
this.postload.splice(idx, 1);
} else {
idx++;
}
}
if (this.postload.length == 0) {
this.postload = undefined; // array obj no longer needed
}
}
//scope.condition_cache.empty();
let needsUpdate = scope.condition_cache.length !== scope.children.length;
scope.condition_cache.length = scope.children.length;