Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
FIX: add observed cache to undo changes mixin
Prevents observer add / remove race conditions which can cause exceptions.
Dieser Commit ist enthalten in:
Ursprung
030929a414
Commit
0e70a5a221
5 geänderte Dateien mit 13 neuen und 5 gelöschten Zeilen
|
@ -4,6 +4,8 @@ import { get, set } from "@ember/object";
|
||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
import { deepEqual } from "discourse-common/lib/object";
|
import { deepEqual } from "discourse-common/lib/object";
|
||||||
|
|
||||||
|
var observedCache = [];
|
||||||
|
|
||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
@ -32,7 +34,10 @@ export default Mixin.create({
|
||||||
};
|
};
|
||||||
|
|
||||||
listProperties(componentType, opts).forEach((property) => {
|
listProperties(componentType, opts).forEach((property) => {
|
||||||
obj.removeObserver(property, this, this.toggleUndo);
|
if (observedCache.includes(property)) {
|
||||||
|
obj.removeObserver(property, this, this.toggleUndo);
|
||||||
|
observedCache = observedCache.filter(p => p !== property);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -45,6 +50,9 @@ export default Mixin.create({
|
||||||
};
|
};
|
||||||
|
|
||||||
listProperties(componentType, opts).forEach((property) => {
|
listProperties(componentType, opts).forEach((property) => {
|
||||||
|
if (observedCache.indexOf(property) === -1) {
|
||||||
|
observedCache.push(property);
|
||||||
|
}
|
||||||
obj.addObserver(property, this, this.toggleUndo);
|
obj.addObserver(property, this, this.toggleUndo);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
||||||
# version: 2.2.6
|
# version: 2.2.7
|
||||||
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
|
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact_emails: development@pavilion.tech
|
# contact_emails: development@pavilion.tech
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
//= require_tree_discourse
|
//= require_tree_discourse
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
//= require_tree_discourse dummy_path
|
//= require_tree_discourse dummy_path
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
//= require_tree_discourse sptest
|
//= require_tree_discourse sptest
|
||||||
|
|
Laden …
In neuem Issue referenzieren