mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 11:45:21 -05:00
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:
+6
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user