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

Commit 82ae339

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

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Controller from "@ember/controller";
33
import { action } from "@ember/object";
44
import { getOwner } from "@ember/owner";
55
import { service } from "@ember/service";
6+
import { TrackedArray } from "@ember-compat/tracked-built-ins";
67
import { popupAjaxError } from "discourse/lib/ajax-error";
78
import UppyUpload from "discourse/lib/uppy/uppy-upload";
89
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
@@ -15,7 +16,7 @@ export default class DiscourseAiBotConversations extends Controller {
1516
@service site;
1617
@service siteSettings;
1718

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

2122
textarea = null;
@@ -46,8 +47,6 @@ export default class DiscourseAiBotConversations extends Controller {
4647
init() {
4748
super.init(...arguments);
4849

49-
this.uploads = [];
50-
5150
this.uppyUpload = new UppyUpload(getOwner(this), {
5251
id: "ai-bot-file-uploader",
5352
type: "ai-bot-conversation",
@@ -85,7 +84,7 @@ export default class DiscourseAiBotConversations extends Controller {
8584
},
8685

8786
uploadDone: (upload) => {
88-
this.uploads.pushObject(upload);
87+
this.uploads.push(upload);
8988
},
9089

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

163162
@action
164163
removeUpload(upload) {
165-
this.uploads.removeObject(upload);
164+
this.uploads = new TrackedArray(this.uploads.filter((u) => u !== upload));
166165
}
167166

168167
@action
@@ -178,7 +177,7 @@ export default class DiscourseAiBotConversations extends Controller {
178177
this.aiBotConversationsHiddenSubmit.uploads = this.uploads;
179178
try {
180179
await this.aiBotConversationsHiddenSubmit.submitToBot();
181-
this.uploads.clear();
180+
this.uploads = new TrackedArray();
182181
} catch (error) {
183182
popupAjaxError(error);
184183
}

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)