@@ -36,6 +36,7 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
36
36
@tracked endCurrentMeeting = false ;
37
37
@tracked translationChannels = [ ] ;
38
38
@tracked translationChannelsNew = [ ] ;
39
+ @tracked translationChannelsRemoved = [ ] ;
39
40
40
41
@computed
41
42
get currentLocale ( ) {
@@ -99,18 +100,28 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
99
100
100
101
async loadTranslationChannels ( ) {
101
102
const videoStreamId = this . data . stream . get ( 'id' ) ; // Get the current video stream id from the route
102
- const responseData = await this . loader . load ( `/video-streams/${ videoStreamId } /translation_channels` ) ;
103
- this . translationChannels = responseData . data . map ( channel => channel . attributes ) ;
104
- this . translationChannels = responseData . data . map ( channel => ( {
105
- id : channel . id ,
106
- ...channel . attributes
107
- } ) ) ;
103
+ if ( videoStreamId ) {
104
+ const responseData = await this . loader . load ( `/video-streams/${ videoStreamId } /translation_channels` ) ;
105
+ this . translationChannels = responseData . data . map ( channel => channel . attributes ) ;
106
+ this . translationChannels = responseData . data . map ( channel => ( {
107
+ id : channel . id ,
108
+ ...channel . attributes
109
+ } ) ) ;
110
+ }
108
111
}
109
112
110
113
@action
111
114
async removeChannel ( index , id ) {
112
- this . translationChannels = this . translationChannels . filter ( ( _ , i ) => i !== index ) ;
113
- this . loader . delete ( `/translation_channels/${ id } ` ) ;
115
+ if ( id ) {
116
+ this . translationChannels = this . translationChannels . filter ( ( _ , i ) => i !== index ) ;
117
+ this . translationChannelsRemoved . push ( id ) ;
118
+ } else {
119
+ this . translationChannelsNew = this . translationChannelsNew . filter ( ( _ , i ) => i !== index ) ;
120
+ }
121
+ }
122
+
123
+ async deletedChannels ( ) {
124
+ this . translationChannelsRemoved . forEach ( id => this . loader . delete ( `/translation_channels/${ id } ` ) ) ;
114
125
}
115
126
116
127
@action
@@ -129,7 +140,6 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
129
140
130
141
@action
131
142
async updateChannel ( index , id ) {
132
- event . preventDefault ( ) ;
133
143
const channel = this . translationChannels [ index ] ;
134
144
const payload = {
135
145
data : {
@@ -149,7 +159,7 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
149
159
channel : {
150
160
data : {
151
161
type : 'video_channel' ,
152
- id : ` ${ channel . id } `
162
+ id : this . data . stream . videoChannel . get ( 'id' )
153
163
}
154
164
}
155
165
}
@@ -331,7 +341,6 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
331
341
332
342
@action
333
343
addChannel ( ) {
334
- event . preventDefault ( ) ;
335
344
this . translationChannelsNew = [ ...this . translationChannelsNew , { id : '' , name : '' , url : '' } ] ;
336
345
}
337
346
@@ -410,7 +419,6 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
410
419
411
420
@action
412
421
addNewChannel ( channel ) {
413
- event . preventDefault ( ) ;
414
422
const payload = {
415
423
'data' : {
416
424
'type' : 'translation_channel' ,
@@ -428,7 +436,7 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
428
436
'channel' : {
429
437
'data' : {
430
438
'type' : 'video_channel' ,
431
- 'id' : '1'
439
+ 'id' : this . data . stream . videoChannel . get ( 'id' )
432
440
}
433
441
}
434
442
}
@@ -446,6 +454,13 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
446
454
this . onValid ( async ( ) => {
447
455
try {
448
456
this . set ( 'isLoading' , true ) ;
457
+ if ( this . data . stream . extra ?. bbb_options ) {
458
+ this . data . stream . extra . bbb_options . endCurrentMeeting = this
459
+ . showUpdateOptions
460
+ ? this . endCurrentMeeting
461
+ : false ;
462
+ }
463
+ await this . data . stream . save ( ) ;
449
464
for ( const channel of this . translationChannelsNew ) {
450
465
this . addNewChannel ( channel ) ;
451
466
}
@@ -454,13 +469,9 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
454
469
this . updateChannel ( index , channel . id ) ;
455
470
} ) ;
456
471
457
- if ( this . data . stream . extra ?. bbb_options ) {
458
- this . data . stream . extra . bbb_options . endCurrentMeeting = this
459
- . showUpdateOptions
460
- ? this . endCurrentMeeting
461
- : false ;
472
+ if ( this . translationChannelsRemoved . length > 0 ) {
473
+ this . deletedChannels ( ) ;
462
474
}
463
- await this . data . stream . save ( ) ;
464
475
const saveModerators = this . data . stream . moderators
465
476
. toArray ( )
466
477
. map ( moderator => {
0 commit comments