Skip to content

Commit 03b5f09

Browse files
authored
DEV: refactor buffered property use in teambuild-target (#98)
Follow up from discourse/discourse#31926. This is to unblock removal of the buffered-content mixin from core. Opted to keep to the classic computed way of declaring this, otherwise I think we would have to convert the whole component to glimmer first.
1 parent bef709a commit 03b5f09

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

assets/javascripts/discourse/components/teambuild-target.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ import Component from "@ember/component";
22
import { computed } from "@ember/object";
33
import { equal, or } from "@ember/object/computed";
44
import { underscore } from "@ember/string";
5+
import BufferedProxy from "ember-buffered-proxy/proxy";
56
import { popupAjaxError } from "discourse/lib/ajax-error";
6-
import { bufferedProperty } from "discourse/mixins/buffered-content";
77
import { Types } from "discourse/plugins/discourse-teambuild/discourse/models/teambuild-target";
88

9-
export default Component.extend(bufferedProperty("target"), {
9+
export default Component.extend({
1010
tagName: "",
1111
editSelected: false,
1212

1313
needsGroup: equal("buffered.target_type_id", Types.USER_GROUP),
1414

15+
buffered: computed("target", function () {
16+
return BufferedProxy.create({
17+
content: this.get("target"),
18+
});
19+
}),
20+
1521
canMoveUp: computed("editing", "index", function () {
1622
return !this.editing && this.index > 0;
1723
}),
@@ -62,7 +68,7 @@ export default Component.extend(bufferedProperty("target"), {
6268
return this.removeTarget();
6369
} else {
6470
this.set("editSelected", false);
65-
this.rollbackBuffer();
71+
this.buffered.discardChanges();
6672
}
6773
},
6874
destroy() {

0 commit comments

Comments
 (0)