@@ -3,6 +3,7 @@ import Controller from "@ember/controller";
3
3
import { action } from "@ember/object" ;
4
4
import { getOwner } from "@ember/owner" ;
5
5
import { service } from "@ember/service" ;
6
+ import { TrackedArray } from "@ember-compat/tracked-built-ins" ;
6
7
import { popupAjaxError } from "discourse/lib/ajax-error" ;
7
8
import UppyUpload from "discourse/lib/uppy/uppy-upload" ;
8
9
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin" ;
@@ -15,7 +16,7 @@ export default class DiscourseAiBotConversations extends Controller {
15
16
@service site ;
16
17
@service siteSettings ;
17
18
18
- @tracked uploads = [ ] ;
19
+ @tracked uploads = new TrackedArray ( ) ;
19
20
// Don't track this directly - we'll get it from uppyUpload
20
21
21
22
textarea = null ;
@@ -46,8 +47,6 @@ export default class DiscourseAiBotConversations extends Controller {
46
47
init ( ) {
47
48
super . init ( ...arguments ) ;
48
49
49
- this . uploads = [ ] ;
50
-
51
50
this . uppyUpload = new UppyUpload ( getOwner ( this ) , {
52
51
id : "ai-bot-file-uploader" ,
53
52
type : "ai-bot-conversation" ,
@@ -85,7 +84,7 @@ export default class DiscourseAiBotConversations extends Controller {
85
84
} ,
86
85
87
86
uploadDone : ( upload ) => {
88
- this . uploads . pushObject ( upload ) ;
87
+ this . uploads . push ( upload ) ;
89
88
} ,
90
89
91
90
// Fix: Don't try to set inProgressUploads directly
@@ -162,7 +161,7 @@ export default class DiscourseAiBotConversations extends Controller {
162
161
163
162
@action
164
163
removeUpload ( upload ) {
165
- this . uploads . removeObject ( upload ) ;
164
+ this . uploads = new TrackedArray ( this . uploads . filter ( ( u ) => u !== upload ) ) ;
166
165
}
167
166
168
167
@action
@@ -178,7 +177,7 @@ export default class DiscourseAiBotConversations extends Controller {
178
177
this . aiBotConversationsHiddenSubmit . uploads = this . uploads ;
179
178
try {
180
179
await this . aiBotConversationsHiddenSubmit . submitToBot ( ) ;
181
- this . uploads . clear ( ) ;
180
+ this . uploads = new TrackedArray ( ) ;
182
181
} catch ( error ) {
183
182
popupAjaxError ( error ) ;
184
183
}
0 commit comments