From 7c1d2c338fa8f48002e22a7c6252af411ceea9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Mon, 1 Dec 2025 19:40:20 -0300 Subject: [PATCH] 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. --- .../discourse/components/teambuild-choice.gjs | 3 +-- .../discourse/models/teambuild-progress.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/components/teambuild-choice.gjs b/assets/javascripts/discourse/components/teambuild-choice.gjs index f2039b2..1235484 100644 --- a/assets/javascripts/discourse/components/teambuild-choice.gjs +++ b/assets/javascripts/discourse/components/teambuild-choice.gjs @@ -1,12 +1,11 @@ import Component from "@ember/component"; -import { action, computed } from "@ember/object"; +import { action } from "@ember/object"; import { tagName } from "@ember-decorators/component"; import DButton from "discourse/components/d-button"; import icon from "discourse/helpers/d-icon"; @tagName("") export default class TeambuildChoice extends Component { - @computed("progress.completed.[]") get completed() { return this.progress.isComplete(this.target, this.userId); } diff --git a/assets/javascripts/discourse/models/teambuild-progress.js b/assets/javascripts/discourse/models/teambuild-progress.js index 264d439..b98e255 100644 --- a/assets/javascripts/discourse/models/teambuild-progress.js +++ b/assets/javascripts/discourse/models/teambuild-progress.js @@ -1,4 +1,9 @@ import { popupAjaxError } from "discourse/lib/ajax-error"; +import { + addUniqueValueToArray, + removeValueFromArray, +} from "discourse/lib/array-tools"; +import { trackedArray } from "discourse/lib/tracked-tools"; import RestModel from "discourse/models/rest"; function choiceKey(target, userId) { @@ -6,6 +11,8 @@ function choiceKey(target, userId) { } export default class TeambuildProgress extends RestModel { + @trackedArray completed = []; + isComplete(target, userId) { return this.completed.includes(choiceKey(target, userId)); } @@ -14,7 +21,7 @@ export default class TeambuildProgress extends RestModel { target .complete(userId) .then(() => { - this.completed.addObject(choiceKey(target, userId)); + addUniqueValueToArray(this.completed, choiceKey(target, userId)); }) .catch(popupAjaxError); } @@ -23,7 +30,7 @@ export default class TeambuildProgress extends RestModel { target .undo(userId) .then(() => { - this.completed.removeObject(choiceKey(target, userId)); + removeValueFromArray(this.completed, choiceKey(target, userId)); }) .catch(popupAjaxError); }