@@ -3,6 +3,7 @@ import Controller from "@ember/controller";
33import { action } from "@ember/object" ;
44import { getOwner } from "@ember/owner" ;
55import { service } from "@ember/service" ;
6+ import { TrackedArray } from "@ember-compat/tracked-built-ins" ;
67import { popupAjaxError } from "discourse/lib/ajax-error" ;
78import UppyUpload from "discourse/lib/uppy/uppy-upload" ;
89import 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 }
0 commit comments