Skip to content

A platform for community discussion. Free, open, simple.

DEV: Replace deprecated Ember's array `toArray` (#35290)

Sérgio Saquetim079bf690c0cc
diff --git a/app/assets/javascripts/discourse/app/deprecation-workflow.js b/app/assets/javascripts/discourse/app/deprecation-workflow.js
index 5fd8dd8b1bb..a8ee43106b0 100644
--- a/app/assets/javascripts/discourse/app/deprecation-workflow.js
+++ b/app/assets/javascripts/discourse/app/deprecation-workflow.js
@@ -305,6 +305,10 @@ const DeprecationWorkflow = new DiscourseDeprecationWorkflow([
handler: "log",
matchId: "discourse.native-array-extensions.sortBy",
},
+ {
+ handler: "log",
+ matchId: "discourse.native-array-extensions.toArray",
+ },
{
handler: "log",
matchId: "discourse.native-array-extensions.without",
diff --git a/app/assets/javascripts/discourse/app/widgets/post-stream.js b/app/assets/javascripts/discourse/app/widgets/post-stream.js
index 5b47c540b6b..6160bd085b3 100644
--- a/app/assets/javascripts/discourse/app/widgets/post-stream.js
+++ b/app/assets/javascripts/discourse/app/widgets/post-stream.js
@@ -5,7 +5,9 @@ import { addWidgetCleanCallback } from "discourse/components/mount-widget";
import discourseDebounce from "discourse/lib/debounce";
import { registerDeprecationHandler } from "discourse/lib/deprecated";
import { iconNode } from "discourse/lib/icon-library";
-import { Placeholder } from "discourse/lib/posts-with-placeholders";
+import PostsWithPlaceholders, {
+ Placeholder,
+} from "discourse/lib/posts-with-placeholders";
import { consolePrefix } from "discourse/lib/source-identifier";
import transformPost from "discourse/lib/transform-post";
import DiscourseURL from "discourse/lib/url";
@@ -214,7 +216,8 @@ export default createWidget("post-stream", {
html(attrs) {
const posts = attrs.posts || [];
- const postArray = posts.toArray();
+ const postArray =
+ posts instanceof PostsWithPlaceholders ? posts.toArray() : posts;
const postArrayLength = postArray.length;
const maxPostNumber =
postArrayLength > 0 ? postArray[postArrayLength - 1].post_number : 0;
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features-list.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features-list.gjs
index 6c829c8ebd7..3491ff6d3ee 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features-list.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features-list.gjs
@@ -11,8 +11,7 @@ export default class AiFeaturesList extends Component {
@service router;
get sortedModules() {
- const modules = this.args.modules?.toArray() || this.args.modules;
- return [...(modules || [])].toSorted((a, b) =>
+ return (this.args.modules || []).toSorted((a, b) =>
(a.module_name || "").localeCompare(b.module_name || "")
);
}
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features.gjs
index 8c762fc0d5c..5581835e283 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-features.gjs
@@ -55,7 +55,7 @@ export default class AiFeatures extends Component {
return [];
}
- let features = this.args.features;
+ let features = this.args.features.toArray();
if (this.selectedFeatureGroup === CONFIGURED) {
features = features.filter((feature) => feature.module_enabled === true);