Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit c640c62

Browse files
committed
DEV: Move to trackedArray
1 parent b66b174 commit c640c62

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

assets/javascripts/discourse/controllers/discourse-ai-bot-conversations.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { tracked } from "@glimmer/tracking";
21
import Controller from "@ember/controller";
32
import { action } from "@ember/object";
43
import { getOwner } from "@ember/owner";
54
import { service } from "@ember/service";
5+
import { TrackedArray } from "@ember-compat/tracked-built-ins";
66
import { popupAjaxError } from "discourse/lib/ajax-error";
77
import UppyUpload from "discourse/lib/uppy/uppy-upload";
88
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
@@ -15,7 +15,7 @@ export default class DiscourseAiBotConversations extends Controller {
1515
@service site;
1616
@service siteSettings;
1717

18-
@tracked uploads = [];
18+
uploads = new TrackedArray([]);
1919
// Don't track this directly - we'll get it from uppyUpload
2020

2121
textarea = null;
@@ -46,7 +46,7 @@ export default class DiscourseAiBotConversations extends Controller {
4646
init() {
4747
super.init(...arguments);
4848

49-
this.uploads = [];
49+
this.uploads = new TrackedArray([]);
5050

5151
this.uppyUpload = new UppyUpload(getOwner(this), {
5252
id: "ai-bot-file-uploader",
@@ -85,7 +85,7 @@ export default class DiscourseAiBotConversations extends Controller {
8585
},
8686

8787
uploadDone: (upload) => {
88-
this.uploads.pushObject(upload);
88+
this.uploads.push(upload);
8989
},
9090

9191
// Fix: Don't try to set inProgressUploads directly
@@ -162,7 +162,7 @@ export default class DiscourseAiBotConversations extends Controller {
162162

163163
@action
164164
removeUpload(upload) {
165-
this.uploads.removeObject(upload);
165+
this.uploads = new TrackedArray(this.uploads.filter((u) => u !== upload));
166166
}
167167

168168
@action
@@ -178,7 +178,7 @@ export default class DiscourseAiBotConversations extends Controller {
178178
this.aiBotConversationsHiddenSubmit.uploads = this.uploads;
179179
try {
180180
await this.aiBotConversationsHiddenSubmit.submitToBot();
181-
this.uploads.clear();
181+
this.uploads = new TrackedArray([]);
182182
} catch (error) {
183183
popupAjaxError(error);
184184
}

spec/system/ai_bot/homepage_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148

149149
find(".ai-bot-upload__remove").click
150150

151-
expect(page).to have_no_css(".ai-bot-upload", wait: 5)
151+
expect(page).to have_no_css(".ai-bot-upload")
152152

153153
ai_pm_homepage.input.fill_in(with: "Message without attachments")
154154

0 commit comments

Comments
 (0)