two concurrent saves could land out of order
This commit is contained in:
1 parent
d3fb5b4383
commit
3ac82877f7
1 file changed
+11
-2
@@ -97,11 +97,20 @@ module.exports = class RibbonClasp extends Plugin {
|
||||
this.mergeNewItems(ribbon);
|
||||
}
|
||||
|
||||
// a drag saves, and the dom change it makes wakes the observer up, which can
|
||||
// save again before the first one has finished writing. queue them instead.
|
||||
save() {
|
||||
this.writing = Promise.resolve(this.writing)
|
||||
.catch(() => {})
|
||||
.then(() => this.saveData(this.settings));
|
||||
return this.writing;
|
||||
}
|
||||
|
||||
recordOrder(ribbon) {
|
||||
const ids = ribbon.items.map((item) => item.id);
|
||||
if (this.sameOrder(ids, this.settings.order)) return;
|
||||
this.settings.order = ids;
|
||||
this.saveData(this.settings);
|
||||
this.save();
|
||||
}
|
||||
|
||||
// only append icons we haven't seen before instead of overwriting the
|
||||
@@ -113,7 +122,7 @@ module.exports = class RibbonClasp extends Plugin {
|
||||
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);
|
||||
this.save();
|
||||
}
|
||||
|
||||
sameOrder(a, b) {
|
||||
|
||||
Reference in new issue
Block a user