DEV: Replace deprecated Ember's array sortBy with sort (#34998)

This Pull Request introduces changes that replace the use of .sortBy
with .sort combined with compare from @ember/utils. This update aims to
modernize and standardize sorting operations throughout the codebase.

**Main Changes:**

* Replaced .sortBy with .sort and compare in various components,
controllers, and services to improve sorting practices.
* Updated sorting logic to handle optional chaining (?.) for increased
robustness.
* Adjusted sorting logic, including reversing, in some cases for more
clarity and correctness.
* Added a new deprecation workflow entry to handle sortBy deprecation
logs (discourse.native-array-extensions.sortBy).
This commit is contained in:
Sérgio Saquetim
2025-09-26 13:38:26 -03:00
committed by GitHub
parent 49ed4be80b
commit 14fef6598c
16 changed files with 76 additions and 37 deletions
@@ -4,6 +4,7 @@ import { fn } from "@ember/helper";
import { action } from "@ember/object";
import { LinkTo } from "@ember/routing";
import { service } from "@ember/service";
import { compare } from "@ember/utils";
import DButton from "discourse/components/d-button";
import replaceEmoji from "discourse/helpers/replace-emoji";
import { ajax } from "discourse/lib/ajax";
@@ -17,7 +18,11 @@ export default class AdminChatIncomingWebhooksList extends Component {
@tracked loading = false;
get sortedWebhooks() {
return this.args.webhooks?.sortBy("updated_at").reverse() || [];
return (
this.args.webhooks?.sort(
(a, b) => compare(b?.updated_at, a?.updated_at) // sort descending
) || []
);
}
@action