Skip to content

Commit 7c1d2c3

Browse files
committed
DEV: Remove deprecated Ember array methods
Eliminate the use of deprecated computed properties in `teambuild-choice.gjs` and replace them with tracked properties in `teambuild-progress.js`. This update enhances code maintainability and aligns with the latest Ember standards. The changes ensure that the application remains functional and up-to-date with current best practices, reducing potential issues with deprecated features.
1 parent 9367e0a commit 7c1d2c3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

assets/javascripts/discourse/components/teambuild-choice.gjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import Component from "@ember/component";
2-
import { action, computed } from "@ember/object";
2+
import { action } from "@ember/object";
33
import { tagName } from "@ember-decorators/component";
44
import DButton from "discourse/components/d-button";
55
import icon from "discourse/helpers/d-icon";
66

77
@tagName("")
88
export default class TeambuildChoice extends Component {
9-
@computed("progress.completed.[]")
109
get completed() {
1110
return this.progress.isComplete(this.target, this.userId);
1211
}

assets/javascripts/discourse/models/teambuild-progress.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import { popupAjaxError } from "discourse/lib/ajax-error";
2+
import {
3+
addUniqueValueToArray,
4+
removeValueFromArray,
5+
} from "discourse/lib/array-tools";
6+
import { trackedArray } from "discourse/lib/tracked-tools";
27
import RestModel from "discourse/models/rest";
38

49
function choiceKey(target, userId) {
510
return `${target.id}:${userId}`;
611
}
712

813
export default class TeambuildProgress extends RestModel {
14+
@trackedArray completed = [];
15+
916
isComplete(target, userId) {
1017
return this.completed.includes(choiceKey(target, userId));
1118
}
@@ -14,7 +21,7 @@ export default class TeambuildProgress extends RestModel {
1421
target
1522
.complete(userId)
1623
.then(() => {
17-
this.completed.addObject(choiceKey(target, userId));
24+
addUniqueValueToArray(this.completed, choiceKey(target, userId));
1825
})
1926
.catch(popupAjaxError);
2027
}
@@ -23,7 +30,7 @@ export default class TeambuildProgress extends RestModel {
2330
target
2431
.undo(userId)
2532
.then(() => {
26-
this.completed.removeObject(choiceKey(target, userId));
33+
removeValueFromArray(this.completed, choiceKey(target, userId));
2734
})
2835
.catch(popupAjaxError);
2936
}

0 commit comments

Comments
 (0)