Skip to content

Commit 24516af

Browse files
authored
Fix #9056 include dropdown of languages (#9059)
* Update side-panel.ts * Update side-panel.hbs * Update side-panel.hbs
1 parent 84f6f07 commit 24516af

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@
5959
<div class="chat-video-room">
6060
<div>
6161
<div class="ui inverted vertical fluid menu borderless stream-side-menu">
62-
{{#each this.streams as |stream index|}}
62+
{{#each this.streams as |stream|}}
6363
<a href={{href-to 'public.stream.view' @event stream.slugName stream.id }} class="{{if (eq @currentRoom.microlocationId stream.microlocationId) 'video-active'}} item stream-item d-flex items-center" {{on "click" (fn @setupRoomChat stream) }}>
6464

6565
<span class="stream-preview-letter" style={{css background-color=(object-at (abs (mod stream.hash this.colors.length)) this.colors)}}>{{truncate (uppercase stream.name) 1 false}}</span>
6666
<span class="ml-2">{{stream.name}}</span>
67-
{{#if (eq index 0)}}
68-
{{#if (gt this.translationChannels.length 1)}}
67+
{{#if (gt stream.translations.length 1)}}
6968
<div style="display:inline-block;margin-left:auto">
7069
<div class="translation-dropdown-button translation-dropdown-container ">
7170
<UiDropdown class="btn btn-secondary dropdown-toggle"
@@ -75,22 +74,21 @@
7574
<i style="font-size:1.1em" class="language icon"></i>
7675
</div>
7776
<div class="translation-dropdown-component">
78-
{{this.translationChannels.length}} {{t 'languages'}}
77+
{{stream.translations.length}} {{t 'languages'}}
7978
</div>
8079
<div class="translation-dropdown-component">
8180
<i style="margin-left: 0 !important;text-align: right;"
8281
class="dropdown icon"> </i>
8382
</div>
8483
</div>
8584
<div class="ui translation menu">
86-
{{#each-in this.translationChannels as |key channel|}}
85+
{{#each-in stream.translations as |key channel|}}
8786
<div class="item" data-value="{{channel.url}}">{{channel.name}}</div>
8887
{{/each-in}}
8988
</div>
9089
</UiDropdown>
9190
</div>
9291
</div>
93-
{{/if}}
9492
{{/if}}
9593
</a>
9694

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class PublicStreamSidePanel extends Component<Args> {
6565
'lightcoral', 'lightsalmon', 'lightseagreen', 'limegreen',
6666
'maroon', 'mediumorchid', 'mediumpurple', 'mediumspringgreen'];
6767

68-
async fetchTranslationChannels(streamId: string): Promise<void> {
68+
async fetchTranslationChannels(streamId: string): Promise<any[] | undefined> {
6969
const response = await this.loader.load(`/video-streams/${streamId}/translation_channels`);
7070
if (response.data !== undefined && response.data.length > 0) {
7171
const newChannels = response.data.map((channel: ChannelData) => ({
@@ -74,9 +74,10 @@ export default class PublicStreamSidePanel extends Component<Args> {
7474
url : channel.attributes.url
7575
}));
7676
// Append newChannels to the existing translationChannels list
77-
this.translationChannels = [...this.translationChannels, ...newChannels];
78-
// eslint-disable-next-line no-mixed-spaces-and-tabs
77+
const res = [...this.translationChannels, ...newChannels];
78+
return res;
7979
}
80+
return undefined;
8081
}
8182

8283
async checkSpeakers(): Promise<void> {
@@ -113,9 +114,6 @@ export default class PublicStreamSidePanel extends Component<Args> {
113114

114115
@action
115116
async setup(): Promise<void> {
116-
if (this.args.videoStream) {
117-
this.fetchTranslationChannels(this.args.videoStream.id);
118-
}
119117
this.shown = this.args.shown || Boolean(new URLSearchParams(location.search).get('side_panel'));
120118
this.addStream(this.args.event.belongsTo('videoStream').value());
121119

@@ -138,7 +136,9 @@ export default class PublicStreamSidePanel extends Component<Args> {
138136
chatRoomName : rooms.data.filter((room: any) => room.relationships['video-stream'].data ? room.relationships['video-stream'].data.id === stream.id : null).map((room: any) => room.attributes['chat-room-name'])[0],
139137
microlocationId : rooms.data.filter((room: any) => room.relationships['video-stream'].data ? room.relationships['video-stream'].data.id === stream.id : null).map((room: any) => room.id)[0],
140138
hash : stringHashCode(stream.attributes.name + stream.id)
141-
})).forEach((stream: any) => {
139+
})).forEach(async(stream: any) => {
140+
const res = await this.fetchTranslationChannels(stream.id)
141+
stream.translations = res
142142
this.addStream(stream)
143143
});
144144
} catch (e) {

0 commit comments

Comments
 (0)