Skip to content

Commit fae3a2a

Browse files
Hieu Lam - TMAkhangon
andauthored
fix-9065: Video auto save when remove the second Source URL (#9072)
* feature-9065: Video auto save when remove the second Source URL * feature-9065: Video auto save when remove the second Source URL * feature-9065: Video auto save when remove the second Source URL * feature-9065: Video auto save when remove the second Source URL * fix-9065: Video auto save when remove the second Source URL * fix-9065: Video auto save when remove the second Source URL * fix-9065: Video auto save when remove the second Source URL --------- Co-authored-by: Khang On - TMA <[email protected]>
1 parent c82286a commit fae3a2a

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

app/components/forms/events/view/videoroom-form.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
<i style="margin-left: 0 !important;text-align: right;"
277277
class="dropdown icon"> </i>
278278
</UiDropdown>
279-
<button class="ml-2 ui icon red button" {{on "click" (fn this.removeChannel index channel.id )}}>
279+
<button class="ml-2 ui icon red button" {{action "removeChannel" index channel.id }}>
280280
<i class="remove icon"></i>
281281
</button>
282282
</div>
@@ -307,7 +307,7 @@
307307
class="dropdown icon"> </i>
308308
</UiDropdown>
309309
<span class="ml-2"></span>
310-
<button class="ui icon red button" {{on "click" (fn this.removeChannel index channel.id )}}>
310+
<button class="ui icon red button" {{action "removeChannel" index channel.id}}>
311311
<i class="remove icon"></i>
312312
</button>
313313
</div>
@@ -317,7 +317,7 @@
317317

318318
{{/each}}
319319
<div class="field">
320-
<button class="ui primary button" {{on "click" this.addChannel }} >
320+
<button class="ui primary button" {{action "addChannel"}} >
321321
{{t 'Add Channel'}}
322322
</button>
323323
</div>

app/components/forms/events/view/videoroom-form.js

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
3636
@tracked endCurrentMeeting = false;
3737
@tracked translationChannels = [];
3838
@tracked translationChannelsNew = [];
39+
@tracked translationChannelsRemoved = [];
3940

4041
@computed
4142
get currentLocale() {
@@ -99,18 +100,28 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
99100

100101
async loadTranslationChannels() {
101102
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+
}
108111
}
109112

110113
@action
111114
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}`));
114125
}
115126

116127
@action
@@ -129,7 +140,6 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
129140

130141
@action
131142
async updateChannel(index, id) {
132-
event.preventDefault();
133143
const channel = this.translationChannels[index];
134144
const payload = {
135145
data: {
@@ -149,7 +159,7 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
149159
channel: {
150160
data: {
151161
type : 'video_channel',
152-
id : `${channel.id}`
162+
id : this.data.stream.videoChannel.get('id')
153163
}
154164
}
155165
}
@@ -331,7 +341,6 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
331341

332342
@action
333343
addChannel() {
334-
event.preventDefault();
335344
this.translationChannelsNew = [...this.translationChannelsNew, { id: '', name: '', url: '' }];
336345
}
337346

@@ -410,7 +419,6 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
410419

411420
@action
412421
addNewChannel(channel) {
413-
event.preventDefault();
414422
const payload = {
415423
'data': {
416424
'type' : 'translation_channel',
@@ -428,7 +436,7 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
428436
'channel': {
429437
'data': {
430438
'type' : 'video_channel',
431-
'id' : '1'
439+
'id' : this.data.stream.videoChannel.get('id')
432440
}
433441
}
434442
}
@@ -446,6 +454,13 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
446454
this.onValid(async() => {
447455
try {
448456
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();
449464
for (const channel of this.translationChannelsNew) {
450465
this.addNewChannel(channel);
451466
}
@@ -454,13 +469,9 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
454469
this.updateChannel(index, channel.id);
455470
});
456471

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();
462474
}
463-
await this.data.stream.save();
464475
const saveModerators = this.data.stream.moderators
465476
.toArray()
466477
.map(moderator => {

app/components/public/stream/side-panel.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ export default class PublicStreamSidePanel extends Component<Args> {
6666
'maroon', 'mediumorchid', 'mediumpurple', 'mediumspringgreen'];
6767

6868
async fetchTranslationChannels(streamId: string): Promise<any[] | undefined> {
69-
const response = await this.loader.load(`/video-streams/${streamId}/translation_channels`);
70-
if (response.data !== undefined && response.data.length > 0) {
71-
const newChannels = response.data.map((channel: ChannelData) => ({
72-
id : channel.id,
73-
name : channel.attributes.name,
74-
url : channel.attributes.url
75-
}));
76-
// Append newChannels to the existing translationChannels list
77-
const res = [...this.translationChannels, ...newChannels];
78-
return res;
69+
if (streamId) {
70+
const response = await this.loader.load(`/video-streams/${streamId}/translation_channels`);
71+
if (response.data !== undefined && response.data.length > 0) {
72+
const newChannels = response.data.map((channel: ChannelData) => ({
73+
id : channel.id,
74+
name : channel.attributes.name,
75+
url : channel.attributes.url
76+
}));
77+
// Append newChannels to the existing translationChannels list
78+
const res = [...this.translationChannels, ...newChannels];
79+
return res;
80+
}
7981
}
8082
return undefined;
8183
}

0 commit comments

Comments
 (0)