redo message trigger for co-websites

This commit is contained in:
_Bastler
2021-11-03 17:30:13 +01:00
parent a3937fc17f
commit af855344f4
5 changed files with 43 additions and 52 deletions
+9 -34
View File
@@ -27,9 +27,14 @@ interface TouchMoveCoordinates {
y: number;
}
export enum CoWebsiteState {
OPENED,
CLOSED,
}
export type CoWebsite = {
iframe: HTMLIFrameElement,
icon: HTMLDivElement,
state : CoWebsiteState,
position: number
}
@@ -334,10 +339,8 @@ class CoWebsiteManager {
if (newPosition === 0) {
coWebsite.iframe.classList.add('main');
coWebsite.icon.style.display = "none";
} else {
coWebsite.iframe.classList.remove('main');
coWebsite.icon.style.display = "flex";
}
if (newPosition === 1) {
@@ -423,8 +426,9 @@ class CoWebsiteManager {
this.moveLeftPreviousCoWebsite(previousCoWebsite, coWebsite.position);
}
coWebsite.icon.remove();
coWebsite.iframe.remove();
coWebsite.state = CoWebsiteState.CLOSED;
iframeListener.unregisterIframe(coWebsite.iframe);
}
public searchJitsi(): CoWebsite|undefined {
@@ -433,21 +437,6 @@ class CoWebsiteManager {
);
}
private generateCoWebsiteIcon(iframe: HTMLIFrameElement): HTMLDivElement {
const icon = document.createElement("div");
icon.id = "cowebsite-icon-" + iframe.id;
icon.style.display = "none";
const iconImage = document.createElement("img");
iconImage.src = `https://www.google.com/s2/favicons?sz=64&domain_url=${iframe.src}`;
const url = new URL(iframe.src);
iconImage.alt = url.hostname;
icon.appendChild(iconImage);
return icon;
}
public loadCoWebsite(
url: string,
base: string,
@@ -500,23 +489,13 @@ class CoWebsiteManager {
iframe.onload = () => resolve();
});
const icon = this.generateCoWebsiteIcon(iframe);
const coWebsite = {
iframe,
icon,
state : CoWebsiteState.OPENED,
position: position ?? this.coWebsites.length,
};
// Iframe management on mobile
icon.addEventListener("click", () => {
if (this.isSmallScreen()) {
this.moveRightPreviousCoWebsite(coWebsite, 0);
}
});
this.coWebsites.push(coWebsite);
this.cowebsiteSubIconsDom.appendChild(icon);
const onTimeoutPromise = new Promise<void>((resolve) => {
setTimeout(() => resolve(), 2000);
@@ -564,10 +543,6 @@ class CoWebsiteManager {
this.fire();
}
if (coWebsite) {
iframeListener.unregisterIframe(coWebsite.iframe);
}
this.removeCoWebsiteFromStack(coWebsite);
resolve();
})
+1
View File
@@ -13,5 +13,6 @@ export enum DivImportance {
}
export const ON_ACTION_TRIGGER_BUTTON = "onaction";
export const ON_ACTION_TRIGGER_DISABLE = "disable";
export type Box = { xStart: number; yStart: number; xEnd: number; yEnd: number };