1- import { tracked } from "@glimmer/tracking" ;
21import Controller from "@ember/controller" ;
32import { action } from "@ember/object" ;
43import { getOwner } from "@ember/owner" ;
54import { service } from "@ember/service" ;
5+ import { TrackedArray } from "@ember-compat/tracked-built-ins" ;
66import { popupAjaxError } from "discourse/lib/ajax-error" ;
77import UppyUpload from "discourse/lib/uppy/uppy-upload" ;
88import 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 }
0 commit comments