fix order getting wiped while other plugins are still loading
This commit is contained in:
@@ -71,7 +71,7 @@ module.exports = class RibbonOrderLock extends Plugin {
|
||||
ribbon.onChange(true);
|
||||
}
|
||||
|
||||
this.recordOrder(ribbon);
|
||||
this.mergeNewItems(ribbon);
|
||||
}
|
||||
|
||||
recordOrder(ribbon) {
|
||||
@@ -81,6 +81,18 @@ module.exports = class RibbonOrderLock extends Plugin {
|
||||
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) {
|
||||
return a.length === b.length && a.every((id, i) => id === b[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user