diff --git a/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte b/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte index 809d1985..b71a35c0 100644 --- a/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte +++ b/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte @@ -5,6 +5,7 @@ import { coWebsitesNotAsleep, mainCoWebsite } from "../../Stores/CoWebsiteStore"; import { highlightedEmbedScreen } from "../../Stores/EmbedScreensStore"; import type { CoWebsite } from "../../WebRtc/CoWebsiteManager"; + import { iframeStates } from "../../WebRtc/CoWebsiteManager"; import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager"; export let index: number; @@ -35,8 +36,12 @@ if ($mainCoWebsite.iframe.id === coWebsite.iframe.id) { const coWebsites = $coWebsitesNotAsleep; const newMain = $highlightedEmbedScreen ?? coWebsites.length > 1 ? coWebsites[1] : undefined; - if (newMain) { + if (newMain && newMain.iframe.id !== $mainCoWebsite.iframe.id) { coWebsiteManager.goToMain(newMain); + } else if (coWebsiteManager.getMainState() === iframeStates.closed) { + coWebsiteManager.displayMain(); + } else { + coWebsiteManager.hideMain(); } } else { highlightedEmbedScreen.toggleHighlight({ diff --git a/front/src/WebRtc/CoWebsiteManager.ts b/front/src/WebRtc/CoWebsiteManager.ts index 7b7147b3..4d6f482c 100644 --- a/front/src/WebRtc/CoWebsiteManager.ts +++ b/front/src/WebRtc/CoWebsiteManager.ts @@ -10,7 +10,7 @@ import { jitsiFactory } from "./JitsiFactory"; import { gameManager } from "../Phaser/Game/GameManager"; import { LayoutMode } from "./LayoutManager"; -enum iframeStates { +export enum iframeStates { closed = 1, loading, // loading an iframe can be slow, so we show some placeholder until it is ready opened, @@ -75,6 +75,10 @@ class CoWebsiteManager { this.resizeAllIframes(); }); + public getMainState() { + return this.openedMain; + } + get width(): number { return this.cowebsiteDom.clientWidth; } @@ -306,6 +310,27 @@ class CoWebsiteManager { }); } + public displayMain() { + const coWebsite = this.getMainCoWebsite(); + if (coWebsite) { + coWebsite.iframe.style.display = "block"; + } + this.loadMain(); + this.openMain(); + this.fire(); + } + + public hideMain() { + const coWebsite = this.getMainCoWebsite(); + if (coWebsite) { + coWebsite.iframe.style.display = "none"; + } + this.cowebsiteDom.classList.add("closing"); + this.cowebsiteDom.classList.remove("opened"); + this.openedMain = iframeStates.closed; + this.fire(); + } + private closeMain(): void { this.toggleFullScreenIcon(true); this.cowebsiteDom.classList.add("closing"); @@ -631,6 +656,11 @@ class CoWebsiteManager { this.loadMain(coWebsite.widthPercent); } + // Check if the main is hide + if (this.getMainCoWebsite() && this.openedMain === iframeStates.closed) { + this.displayMain(); + } + coWebsite.state.set("loading"); const mainCoWebsite = this.getMainCoWebsite();