Hide main cowebsite
This commit is contained in:
parent
60c17ecea2
commit
75d42209f4
2 changed files with 37 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
||||||
import { coWebsitesNotAsleep, mainCoWebsite } from "../../Stores/CoWebsiteStore";
|
import { coWebsitesNotAsleep, mainCoWebsite } from "../../Stores/CoWebsiteStore";
|
||||||
import { highlightedEmbedScreen } from "../../Stores/EmbedScreensStore";
|
import { highlightedEmbedScreen } from "../../Stores/EmbedScreensStore";
|
||||||
import type { CoWebsite } from "../../WebRtc/CoWebsiteManager";
|
import type { CoWebsite } from "../../WebRtc/CoWebsiteManager";
|
||||||
|
import { iframeStates } from "../../WebRtc/CoWebsiteManager";
|
||||||
import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager";
|
import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager";
|
||||||
|
|
||||||
export let index: number;
|
export let index: number;
|
||||||
|
@ -35,8 +36,12 @@
|
||||||
if ($mainCoWebsite.iframe.id === coWebsite.iframe.id) {
|
if ($mainCoWebsite.iframe.id === coWebsite.iframe.id) {
|
||||||
const coWebsites = $coWebsitesNotAsleep;
|
const coWebsites = $coWebsitesNotAsleep;
|
||||||
const newMain = $highlightedEmbedScreen ?? coWebsites.length > 1 ? coWebsites[1] : undefined;
|
const newMain = $highlightedEmbedScreen ?? coWebsites.length > 1 ? coWebsites[1] : undefined;
|
||||||
if (newMain) {
|
if (newMain && newMain.iframe.id !== $mainCoWebsite.iframe.id) {
|
||||||
coWebsiteManager.goToMain(newMain);
|
coWebsiteManager.goToMain(newMain);
|
||||||
|
} else if (coWebsiteManager.getMainState() === iframeStates.closed) {
|
||||||
|
coWebsiteManager.displayMain();
|
||||||
|
} else {
|
||||||
|
coWebsiteManager.hideMain();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
highlightedEmbedScreen.toggleHighlight({
|
highlightedEmbedScreen.toggleHighlight({
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { jitsiFactory } from "./JitsiFactory";
|
||||||
import { gameManager } from "../Phaser/Game/GameManager";
|
import { gameManager } from "../Phaser/Game/GameManager";
|
||||||
import { LayoutMode } from "./LayoutManager";
|
import { LayoutMode } from "./LayoutManager";
|
||||||
|
|
||||||
enum iframeStates {
|
export enum iframeStates {
|
||||||
closed = 1,
|
closed = 1,
|
||||||
loading, // loading an iframe can be slow, so we show some placeholder until it is ready
|
loading, // loading an iframe can be slow, so we show some placeholder until it is ready
|
||||||
opened,
|
opened,
|
||||||
|
@ -75,6 +75,10 @@ class CoWebsiteManager {
|
||||||
this.resizeAllIframes();
|
this.resizeAllIframes();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
public getMainState() {
|
||||||
|
return this.openedMain;
|
||||||
|
}
|
||||||
|
|
||||||
get width(): number {
|
get width(): number {
|
||||||
return this.cowebsiteDom.clientWidth;
|
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 {
|
private closeMain(): void {
|
||||||
this.toggleFullScreenIcon(true);
|
this.toggleFullScreenIcon(true);
|
||||||
this.cowebsiteDom.classList.add("closing");
|
this.cowebsiteDom.classList.add("closing");
|
||||||
|
@ -631,6 +656,11 @@ class CoWebsiteManager {
|
||||||
this.loadMain(coWebsite.widthPercent);
|
this.loadMain(coWebsite.widthPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the main is hide
|
||||||
|
if (this.getMainCoWebsite() && this.openedMain === iframeStates.closed) {
|
||||||
|
this.displayMain();
|
||||||
|
}
|
||||||
|
|
||||||
coWebsite.state.set("loading");
|
coWebsite.state.set("loading");
|
||||||
|
|
||||||
const mainCoWebsite = this.getMainCoWebsite();
|
const mainCoWebsite = this.getMainCoWebsite();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue