Merge pull request #1880 from thecodingmachine/fix-cowebsite-high-master

Hot fixes for co-websites
This commit is contained in:
David Négrier 2022-02-15 18:19:36 +01:00 committed by GitHub
commit 88bfd537cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 12 deletions

View File

@ -3,7 +3,7 @@
import { streamableCollectionStore } from "../../Stores/StreamableCollectionStore"; import { streamableCollectionStore } from "../../Stores/StreamableCollectionStore";
import MediaBox from "../Video/MediaBox.svelte"; import MediaBox from "../Video/MediaBox.svelte";
export let highlightedEmbedScreen: EmbedScreen | null; export let highlightedEmbedScreen: EmbedScreen | undefined;
export let full = false; export let full = false;
$: clickable = !full; $: clickable = !full;
</script> </script>

View File

@ -73,9 +73,9 @@
$mainCoWebsite !== undefined && $mainCoWebsite !== undefined &&
$mainCoWebsite.getId() === coWebsite.getId(); $mainCoWebsite.getId() === coWebsite.getId();
isHighlight = isHighlight =
$highlightedEmbedScreen !== null && $highlightedEmbedScreen !== undefined &&
$highlightedEmbedScreen.type === "cowebsite" && $highlightedEmbedScreen?.type === "cowebsite" &&
$highlightedEmbedScreen.embed.getId() === coWebsite.getId(); $highlightedEmbedScreen?.embed.getId() === coWebsite.getId();
} }
</script> </script>

View File

@ -15,7 +15,7 @@ export type EmbedScreen =
}; };
function createHighlightedEmbedScreenStore() { function createHighlightedEmbedScreenStore() {
const { subscribe, set, update } = writable<EmbedScreen | null>(null); const { subscribe, set, update } = writable<EmbedScreen | undefined>(undefined);
return { return {
subscribe, subscribe,
@ -23,7 +23,7 @@ function createHighlightedEmbedScreenStore() {
set(embedScreen); set(embedScreen);
}, },
removeHighlight: () => { removeHighlight: () => {
set(null); set(undefined);
}, },
toggleHighlight: (embedScreen: EmbedScreen) => { toggleHighlight: (embedScreen: EmbedScreen) => {
update((currentEmbedScreen) => update((currentEmbedScreen) =>
@ -36,7 +36,7 @@ function createHighlightedEmbedScreenStore() {
currentEmbedScreen.type === "streamable" && currentEmbedScreen.type === "streamable" &&
embedScreen.embed.uniqueId !== currentEmbedScreen.embed.uniqueId) embedScreen.embed.uniqueId !== currentEmbedScreen.embed.uniqueId)
? embedScreen ? embedScreen
: null : undefined
); );
}, },
}; };

View File

@ -159,9 +159,17 @@ class CoWebsiteManager {
}); });
buttonSwipe.addEventListener("click", () => { buttonSwipe.addEventListener("click", () => {
const mainCoWebsite = this.getMainCoWebsite();
const highlightedEmbed = get(highlightedEmbedScreen); const highlightedEmbed = get(highlightedEmbedScreen);
if (highlightedEmbed?.type === "cowebsite") { if (highlightedEmbed?.type === "cowebsite") {
this.goToMain(highlightedEmbed.embed); this.goToMain(highlightedEmbed.embed);
if (mainCoWebsite) {
highlightedEmbedScreen.toggleHighlight({
type: "cowebsite",
embed: mainCoWebsite,
});
}
} }
}); });
} }
@ -553,6 +561,13 @@ class CoWebsiteManager {
coWebsites.remove(coWebsite); coWebsites.remove(coWebsite);
coWebsites.add(coWebsite, 0); coWebsites.add(coWebsite, 0);
if (mainCoWebsite) {
const iframe = mainCoWebsite.getIframe();
if (iframe) {
iframe.style.display = "block";
}
}
if ( if (
isMediaBreakpointDown("lg") && isMediaBreakpointDown("lg") &&
get(embedScreenLayout) === LayoutMode.Presentation && get(embedScreenLayout) === LayoutMode.Presentation &&
@ -596,12 +611,20 @@ class CoWebsiteManager {
.load() .load()
.then(() => { .then(() => {
const mainCoWebsite = this.getMainCoWebsite(); const mainCoWebsite = this.getMainCoWebsite();
if (mainCoWebsite && mainCoWebsite.getId() === coWebsite.getId()) { const highlightedEmbed = get(highlightedEmbedScreen);
if (mainCoWebsite) {
if (mainCoWebsite.getId() === coWebsite.getId()) {
this.openMain(); this.openMain();
setTimeout(() => { setTimeout(() => {
this.fire(); this.fire();
}, animationTime); }, animationTime);
} else if (!highlightedEmbed) {
highlightedEmbedScreen.toggleHighlight({
type: "cowebsite",
embed: coWebsite,
});
}
} }
this.resizeAllIframes(); this.resizeAllIframes();
}) })