our own reorder was tripping the hook and saving over itself
This commit is contained in:
1 parent
7fe98170ba
commit
dc3c5428e2
1 file changed
+7
-1
@@ -13,6 +13,7 @@ function debounce(fn, wait) {
|
||||
module.exports = class RibbonOrderLock extends Plugin {
|
||||
async onload() {
|
||||
this.settings = Object.assign({ order: [] }, await this.loadData());
|
||||
this.enforcing = false;
|
||||
this.debouncedEnforce = debounce(() => this.enforceOrder(), 200);
|
||||
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
@@ -40,7 +41,7 @@ module.exports = class RibbonOrderLock extends Plugin {
|
||||
|
||||
ribbon.onChange = (save) => {
|
||||
original(save);
|
||||
if (save) {
|
||||
if (save && !this.enforcing) {
|
||||
this.recordOrder(ribbon);
|
||||
}
|
||||
};
|
||||
@@ -68,7 +69,12 @@ module.exports = class RibbonOrderLock extends Plugin {
|
||||
if (changed) {
|
||||
ribbon.items.length = 0;
|
||||
ribbon.items.push(...sorted);
|
||||
this.enforcing = true;
|
||||
try {
|
||||
ribbon.onChange(true);
|
||||
} finally {
|
||||
this.enforcing = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.mergeNewItems(ribbon);
|
||||
|
||||
Reference in new issue
Block a user