1
0
Fork 0

FIX: add observed cache to undo changes mixin

Prevents observer add / remove race conditions which can cause exceptions.
Dieser Commit ist enthalten in:
Angus McLeod 2023-03-15 09:22:09 +01:00
Ursprung 030929a414
Commit 0e70a5a221
5 geänderte Dateien mit 13 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -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);
}); });
}, },

Datei anzeigen

@ -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

Datei anzeigen

@ -1 +1 @@
//= require_tree_discourse //= require_tree_discourse

Datei anzeigen

@ -1 +1 @@
//= require_tree_discourse dummy_path //= require_tree_discourse dummy_path

Datei anzeigen

@ -1 +1 @@
//= require_tree_discourse sptest //= require_tree_discourse sptest