workadventure/front/src/Components/Video/ChatLayout.svelte

36 lines
1 KiB
Svelte
Raw Normal View History

2021-06-15 17:30:28 +02:00
<script lang="ts">
2021-12-06 16:12:37 +01:00
import { streamableCollectionStore } from "../../Stores/StreamableCollectionStore";
import { afterUpdate, onDestroy } from "svelte";
import { biggestAvailableAreaStore } from "../../Stores/BiggestAvailableAreaStore";
2021-06-21 14:43:10 +02:00
import MediaBox from "./MediaBox.svelte";
2021-06-15 17:30:28 +02:00
2021-12-06 16:12:37 +01:00
let cssClass = "one-col";
2021-06-15 17:30:28 +02:00
2021-06-21 14:43:10 +02:00
const unsubscribe = streamableCollectionStore.subscribe((displayableMedias) => {
2021-06-15 17:30:28 +02:00
const nbUsers = displayableMedias.size;
if (nbUsers <= 1) {
2021-12-06 16:12:37 +01:00
cssClass = "one-col";
2021-06-15 17:30:28 +02:00
} else if (nbUsers <= 4) {
2021-12-06 16:12:37 +01:00
cssClass = "two-col";
2021-06-15 17:30:28 +02:00
} else if (nbUsers <= 9) {
2021-12-06 16:12:37 +01:00
cssClass = "three-col";
2021-06-15 17:30:28 +02:00
} else {
2021-12-06 16:12:37 +01:00
cssClass = "four-col";
2021-06-15 17:30:28 +02:00
}
});
onDestroy(() => {
unsubscribe();
});
afterUpdate(() => {
biggestAvailableAreaStore.recompute();
2021-12-06 16:12:37 +01:00
});
2021-06-15 17:30:28 +02:00
</script>
<div class="chat-mode {cssClass}">
2021-06-21 14:43:10 +02:00
{#each [...$streamableCollectionStore.values()] as peer (peer.uniqueId)}
2021-12-06 16:12:37 +01:00
<MediaBox streamable={peer} />
2021-06-15 17:30:28 +02:00
{/each}
</div>