fix order getting wiped while other plugins are still loading
This commit is contained in:
1 parent
1dbb3e8ff2
commit
747bfd6770
1 file changed
+13
-1
@@ -71,7 +71,7 @@ module.exports = class RibbonOrderLock extends Plugin {
|
|||||||
ribbon.onChange(true);
|
ribbon.onChange(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.recordOrder(ribbon);
|
this.mergeNewItems(ribbon);
|
||||||
}
|
}
|
||||||
|
|
||||||
recordOrder(ribbon) {
|
recordOrder(ribbon) {
|
||||||
@@ -81,6 +81,18 @@ module.exports = class RibbonOrderLock extends Plugin {
|
|||||||
this.saveData(this.settings);
|
this.saveData(this.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only append icons we haven't seen before instead of overwriting the
|
||||||
|
// whole order -- enforceOrder() runs during boot too, before every
|
||||||
|
// plugin has attached its icon yet, and a full overwrite there was
|
||||||
|
// wiping out the remembered position for anything still loading
|
||||||
|
mergeNewItems(ribbon) {
|
||||||
|
const known = new Set(this.settings.order);
|
||||||
|
const newIds = ribbon.items.map((item) => item.id).filter((id) => !known.has(id));
|
||||||
|
if (newIds.length === 0) return;
|
||||||
|
this.settings.order = [...this.settings.order, ...newIds];
|
||||||
|
this.saveData(this.settings);
|
||||||
|
}
|
||||||
|
|
||||||
sameOrder(a, b) {
|
sameOrder(a, b) {
|
||||||
return a.length === b.length && a.every((id, i) => id === b[i]);
|
return a.length === b.length && a.every((id, i) => id === b[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user