All promises are now handled
This commit is contained in:
parent
6e27ffb2d5
commit
24baf5664c
@ -18,64 +18,84 @@ class AnalyticsClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
identifyUser(uuid: string, email: string | null) {
|
identifyUser(uuid: string, email: string | null) {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.identify(uuid, { uuid, email, wa: true });
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.identify(uuid, { uuid, email, wa: true });
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
loggedWithSso() {
|
loggedWithSso() {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-logged-sso");
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-logged-sso");
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
loggedWithToken() {
|
loggedWithToken() {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-logged-token");
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-logged-token");
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
enteredRoom(roomId: string, roomGroup: string | null) {
|
enteredRoom(roomId: string, roomGroup: string | null) {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("$pageView", { roomId, roomGroup });
|
?.then((posthog) => {
|
||||||
posthog.capture("enteredRoom");
|
posthog.capture("$pageView", { roomId, roomGroup });
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("enteredRoom");
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
openedMenu() {
|
openedMenu() {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-opened-menu");
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-opened-menu");
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
launchEmote(emote: string) {
|
launchEmote(emote: string) {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-emote-launch", { emote });
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-emote-launch", { emote });
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
enteredJitsi(roomName: string, roomId: string) {
|
enteredJitsi(roomName: string, roomId: string) {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-entered-jitsi", { roomName, roomId });
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-entered-jitsi", { roomName, roomId });
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
validationName() {
|
validationName() {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-name-validation");
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-name-validation");
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
validationWoka(scene: string) {
|
validationWoka(scene: string) {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-woka-validation", { scene });
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-woka-validation", { scene });
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
validationVideo() {
|
validationVideo() {
|
||||||
this.posthogPromise?.then((posthog) => {
|
this.posthogPromise
|
||||||
posthog.capture("wa-video-validation");
|
?.then((posthog) => {
|
||||||
}).catch(e => console.error(e));
|
posthog.capture("wa-video-validation");
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const analyticsClient = new AnalyticsClient();
|
export const analyticsClient = new AnalyticsClient();
|
||||||
|
@ -26,7 +26,7 @@ export class ActionMessage {
|
|||||||
this.message = actionMessageOptions.message;
|
this.message = actionMessageOptions.message;
|
||||||
this.type = actionMessageOptions.type ?? "message";
|
this.type = actionMessageOptions.type ?? "message";
|
||||||
this.callback = actionMessageOptions.callback;
|
this.callback = actionMessageOptions.callback;
|
||||||
this.create().catch(e => console.error(e));
|
this.create().catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async create() {
|
private async create() {
|
||||||
|
@ -95,7 +95,7 @@ export function createState(target: "global" | "player"): WorkadventureStateComm
|
|||||||
set(target: WorkadventureStateCommands, p: PropertyKey, value: unknown, receiver: unknown): boolean {
|
set(target: WorkadventureStateCommands, p: PropertyKey, value: unknown, receiver: unknown): boolean {
|
||||||
// Note: when using "set", there is no way to wait, so we ignore the return of the promise.
|
// Note: when using "set", there is no way to wait, so we ignore the return of the promise.
|
||||||
// User must use WA.state.saveVariable to have error message.
|
// User must use WA.state.saveVariable to have error message.
|
||||||
target.saveVariable(p.toString(), value).catch(e => console.error(e));
|
target.saveVariable(p.toString(), value).catch((e) => console.error(e));
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
has(target: WorkadventureStateCommands, p: PropertyKey): boolean {
|
has(target: WorkadventureStateCommands, p: PropertyKey): boolean {
|
||||||
|
@ -33,9 +33,9 @@
|
|||||||
const body = HtmlUtils.querySelectorOrFail("body");
|
const body = HtmlUtils.querySelectorOrFail("body");
|
||||||
if (body) {
|
if (body) {
|
||||||
if (document.fullscreenElement !== null && !fullscreen) {
|
if (document.fullscreenElement !== null && !fullscreen) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen().catch((e) => console.error(e));
|
||||||
} else {
|
} else {
|
||||||
body.requestFullscreen();
|
body.requestFullscreen().catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
localUserStore.setFullscreen(fullscreen);
|
localUserStore.setFullscreen(fullscreen);
|
||||||
}
|
}
|
||||||
@ -45,14 +45,16 @@
|
|||||||
if (Notification.permission === "granted") {
|
if (Notification.permission === "granted") {
|
||||||
localUserStore.setNotification(notification ? "granted" : "denied");
|
localUserStore.setNotification(notification ? "granted" : "denied");
|
||||||
} else {
|
} else {
|
||||||
Notification.requestPermission().then((response) => {
|
Notification.requestPermission()
|
||||||
if (response === "granted") {
|
.then((response) => {
|
||||||
localUserStore.setNotification(notification ? "granted" : "denied");
|
if (response === "granted") {
|
||||||
} else {
|
localUserStore.setNotification(notification ? "granted" : "denied");
|
||||||
localUserStore.setNotification("denied");
|
} else {
|
||||||
notification = false;
|
localUserStore.setNotification("denied");
|
||||||
}
|
notification = false;
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
audio.play();
|
audio.play().catch((e) => console.error(e));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class ConnectionManager {
|
|||||||
|
|
||||||
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
|
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
|
||||||
//use href to keep # value
|
//use href to keep # value
|
||||||
localUserStore.setLastRoomUrl(this._currentRoom.href);
|
await localUserStore.setLastRoomUrl(this._currentRoom.href);
|
||||||
|
|
||||||
//todo: add here some kind of warning if authToken has expired.
|
//todo: add here some kind of warning if authToken has expired.
|
||||||
if (!this.authToken && !this._currentRoom.authenticationMandatory) {
|
if (!this.authToken && !this._currentRoom.authenticationMandatory) {
|
||||||
@ -301,7 +301,7 @@ class ConnectionManager {
|
|||||||
this.reconnectingTimeout = setTimeout(() => {
|
this.reconnectingTimeout = setTimeout(() => {
|
||||||
//todo: allow a way to break recursion?
|
//todo: allow a way to break recursion?
|
||||||
//todo: find a way to avoid recursive function. Otherwise, the call stack will grow indefinitely.
|
//todo: find a way to avoid recursive function. Otherwise, the call stack will grow indefinitely.
|
||||||
this.connectToRoomSocket(roomUrl, name, characterLayers, position, viewport, companion).then(
|
void this.connectToRoomSocket(roomUrl, name, characterLayers, position, viewport, companion).then(
|
||||||
(connection) => resolve(connection)
|
(connection) => resolve(connection)
|
||||||
);
|
);
|
||||||
}, 4000 + Math.floor(Math.random() * 2000));
|
}, 4000 + Math.floor(Math.random() * 2000));
|
||||||
|
@ -136,13 +136,12 @@ class LocalUserStore {
|
|||||||
return localStorage.getItem(ignoreFollowRequests) === "true";
|
return localStorage.getItem(ignoreFollowRequests) === "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
setLastRoomUrl(roomUrl: string): void {
|
async setLastRoomUrl(roomUrl: string): Promise<void> {
|
||||||
localStorage.setItem(lastRoomUrl, roomUrl.toString());
|
localStorage.setItem(lastRoomUrl, roomUrl.toString());
|
||||||
if ("caches" in window) {
|
if ("caches" in window) {
|
||||||
caches.open(cacheAPIIndex).then((cache) => {
|
const cache = await caches.open(cacheAPIIndex);
|
||||||
const stringResponse = new Response(JSON.stringify({ roomUrl }));
|
const stringResponse = new Response(JSON.stringify({ roomUrl }));
|
||||||
cache.put(`/${lastRoomUrl}`, stringResponse);
|
await cache.put(`/${lastRoomUrl}`, stringResponse);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getLastRoomUrl(): string {
|
getLastRoomUrl(): string {
|
||||||
|
@ -352,7 +352,7 @@ export class RoomConnection implements RoomConnection {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "tokenExpiredMessage": {
|
case "tokenExpiredMessage": {
|
||||||
connectionManager.logout();
|
connectionManager.logout().catch((e) => console.error(e));
|
||||||
this.closed = true; //technically, this isn't needed since loadOpenIDScreen() will do window.location.assign() but I prefer to leave it for consistency
|
this.closed = true; //technically, this isn't needed since loadOpenIDScreen() will do window.location.assign() but I prefer to leave it for consistency
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,15 @@ export class Companion extends Container {
|
|||||||
this.companionName = name;
|
this.companionName = name;
|
||||||
this._pictureStore = writable(undefined);
|
this._pictureStore = writable(undefined);
|
||||||
|
|
||||||
texturePromise.then((resource) => {
|
texturePromise
|
||||||
this.addResource(resource);
|
.then((resource) => {
|
||||||
this.invisible = false;
|
this.addResource(resource);
|
||||||
return this.getSnapshot().then((htmlImageElementSrc) => {
|
this.invisible = false;
|
||||||
this._pictureStore.set(htmlImageElementSrc);
|
return this.getSnapshot().then((htmlImageElementSrc) => {
|
||||||
});
|
this._pictureStore.set(htmlImageElementSrc);
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
|
|
||||||
this.scene.physics.world.enableBody(this);
|
this.scene.physics.world.enableBody(this);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { COMPANION_RESOURCES, CompanionResourceDescriptionInterface } from "./Co
|
|||||||
|
|
||||||
export const getAllCompanionResources = (loader: LoaderPlugin): CompanionResourceDescriptionInterface[] => {
|
export const getAllCompanionResources = (loader: LoaderPlugin): CompanionResourceDescriptionInterface[] => {
|
||||||
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {
|
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {
|
||||||
lazyLoadCompanionResource(loader, resource.name);
|
lazyLoadCompanionResource(loader, resource.name).catch((e) => console.error(e));
|
||||||
});
|
});
|
||||||
|
|
||||||
return COMPANION_RESOURCES;
|
return COMPANION_RESOURCES;
|
||||||
|
@ -72,9 +72,11 @@ export class Loader {
|
|||||||
if (this.loadingText) {
|
if (this.loadingText) {
|
||||||
this.loadingText.destroy();
|
this.loadingText.destroy();
|
||||||
}
|
}
|
||||||
promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => {
|
promiseLoadLogoTexture
|
||||||
resLoadingImage.destroy();
|
.then((resLoadingImage: Phaser.GameObjects.Image) => {
|
||||||
});
|
resLoadingImage.destroy();
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
this.progress.destroy();
|
this.progress.destroy();
|
||||||
this.progressContainer.destroy();
|
this.progressContainer.destroy();
|
||||||
if (this.scene instanceof DirtyScene) {
|
if (this.scene instanceof DirtyScene) {
|
||||||
|
@ -123,7 +123,7 @@ export class GameMapPropertiesListener {
|
|||||||
.then((coWebsite) => {
|
.then((coWebsite) => {
|
||||||
const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer);
|
const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer);
|
||||||
if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) {
|
if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) {
|
||||||
coWebsiteManager.closeCoWebsite(coWebsite);
|
coWebsiteManager.closeCoWebsite(coWebsite).catch((e) => console.error(e));
|
||||||
this.coWebsitesOpenByLayer.delete(layer);
|
this.coWebsitesOpenByLayer.delete(layer);
|
||||||
this.coWebsitesActionTriggerByLayer.delete(layer);
|
this.coWebsitesActionTriggerByLayer.delete(layer);
|
||||||
} else {
|
} else {
|
||||||
@ -132,7 +132,8 @@ export class GameMapPropertiesListener {
|
|||||||
state: OpenCoWebsiteState.OPENED,
|
state: OpenCoWebsiteState.OPENED,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
|
|
||||||
layoutManagerActionStore.removeAction(actionUuid);
|
layoutManagerActionStore.removeAction(actionUuid);
|
||||||
};
|
};
|
||||||
@ -198,7 +199,7 @@ export class GameMapPropertiesListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (coWebsiteOpen.coWebsite !== undefined) {
|
if (coWebsiteOpen.coWebsite !== undefined) {
|
||||||
coWebsiteManager.closeCoWebsite(coWebsiteOpen.coWebsite);
|
coWebsiteManager.closeCoWebsite(coWebsiteOpen.coWebsite).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.coWebsitesOpenByLayer.delete(layer);
|
this.coWebsitesOpenByLayer.delete(layer);
|
||||||
|
@ -241,7 +241,7 @@ export class GameScene extends DirtyScene {
|
|||||||
const textures = localUser?.textures;
|
const textures = localUser?.textures;
|
||||||
if (textures) {
|
if (textures) {
|
||||||
for (const texture of textures) {
|
for (const texture of textures) {
|
||||||
loadCustomTexture(this.load, texture);
|
loadCustomTexture(this.load, texture).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ export class GameScene extends DirtyScene {
|
|||||||
this.load.on(
|
this.load.on(
|
||||||
"filecomplete-tilemapJSON-" + this.MapUrlFile,
|
"filecomplete-tilemapJSON-" + this.MapUrlFile,
|
||||||
(key: string, type: string, data: unknown) => {
|
(key: string, type: string, data: unknown) => {
|
||||||
this.onMapLoad(data);
|
this.onMapLoad(data).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -292,14 +292,14 @@ export class GameScene extends DirtyScene {
|
|||||||
this.load.on(
|
this.load.on(
|
||||||
"filecomplete-tilemapJSON-" + this.MapUrlFile,
|
"filecomplete-tilemapJSON-" + this.MapUrlFile,
|
||||||
(key: string, type: string, data: unknown) => {
|
(key: string, type: string, data: unknown) => {
|
||||||
this.onMapLoad(data);
|
this.onMapLoad(data).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// If the map has already been loaded as part of another GameScene, the "on load" event will not be triggered.
|
// If the map has already been loaded as part of another GameScene, the "on load" event will not be triggered.
|
||||||
// In this case, we check in the cache to see if the map is here and trigger the event manually.
|
// In this case, we check in the cache to see if the map is here and trigger the event manually.
|
||||||
if (this.cache.tilemap.exists(this.MapUrlFile)) {
|
if (this.cache.tilemap.exists(this.MapUrlFile)) {
|
||||||
const data = this.cache.tilemap.get(this.MapUrlFile);
|
const data = this.cache.tilemap.get(this.MapUrlFile);
|
||||||
this.onMapLoad(data);
|
this.onMapLoad(data).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ export class GameScene extends DirtyScene {
|
|||||||
});
|
});
|
||||||
this.load.scenePlugin("AnimatedTiles", AnimatedTiles, "animatedTiles", "animatedTiles");
|
this.load.scenePlugin("AnimatedTiles", AnimatedTiles, "animatedTiles", "animatedTiles");
|
||||||
this.load.on("filecomplete-tilemapJSON-" + this.MapUrlFile, (key: string, type: string, data: unknown) => {
|
this.load.on("filecomplete-tilemapJSON-" + this.MapUrlFile, (key: string, type: string, data: unknown) => {
|
||||||
this.onMapLoad(data);
|
this.onMapLoad(data).catch((e) => console.error(e));
|
||||||
});
|
});
|
||||||
//TODO strategy to add access token
|
//TODO strategy to add access token
|
||||||
this.load.tilemapTiledJSON(this.MapUrlFile, this.MapUrlFile);
|
this.load.tilemapTiledJSON(this.MapUrlFile, this.MapUrlFile);
|
||||||
@ -328,7 +328,7 @@ export class GameScene extends DirtyScene {
|
|||||||
// In this case, we check in the cache to see if the map is here and trigger the event manually.
|
// In this case, we check in the cache to see if the map is here and trigger the event manually.
|
||||||
if (this.cache.tilemap.exists(this.MapUrlFile)) {
|
if (this.cache.tilemap.exists(this.MapUrlFile)) {
|
||||||
const data = this.cache.tilemap.get(this.MapUrlFile);
|
const data = this.cache.tilemap.get(this.MapUrlFile);
|
||||||
this.onMapLoad(data);
|
this.onMapLoad(data).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -406,21 +406,23 @@ export class GameScene extends DirtyScene {
|
|||||||
this.load.on("complete", () => {
|
this.load.on("complete", () => {
|
||||||
// FIXME: the factory might fail because the resources might not be loaded yet...
|
// FIXME: the factory might fail because the resources might not be loaded yet...
|
||||||
// We would need to add a loader ended event in addition to the createPromise
|
// We would need to add a loader ended event in addition to the createPromise
|
||||||
this.createPromise.then(async () => {
|
this.createPromise
|
||||||
itemFactory.create(this);
|
.then(async () => {
|
||||||
|
itemFactory.create(this);
|
||||||
|
|
||||||
const roomJoinedAnswer = await this.connectionAnswerPromise;
|
const roomJoinedAnswer = await this.connectionAnswerPromise;
|
||||||
|
|
||||||
for (const object of objectsOfType) {
|
for (const object of objectsOfType) {
|
||||||
// TODO: we should pass here a factory to create sprites (maybe?)
|
// TODO: we should pass here a factory to create sprites (maybe?)
|
||||||
|
|
||||||
// Do we have a state for this object?
|
// Do we have a state for this object?
|
||||||
const state = roomJoinedAnswer.items[object.id];
|
const state = roomJoinedAnswer.items[object.id];
|
||||||
|
|
||||||
const actionableItem = itemFactory.factory(this, object, state);
|
const actionableItem = itemFactory.factory(this, object, state);
|
||||||
this.actionableItems.set(actionableItem.getId(), actionableItem);
|
this.actionableItems.set(actionableItem.getId(), actionableItem);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,11 +488,11 @@ export class GameScene extends DirtyScene {
|
|||||||
if (exitSceneUrl !== undefined) {
|
if (exitSceneUrl !== undefined) {
|
||||||
this.loadNextGame(
|
this.loadNextGame(
|
||||||
Room.getRoomPathFromExitSceneUrl(exitSceneUrl, window.location.toString(), this.MapUrlFile)
|
Room.getRoomPathFromExitSceneUrl(exitSceneUrl, window.location.toString(), this.MapUrlFile)
|
||||||
);
|
).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
const exitUrl = this.getExitUrl(layer);
|
const exitUrl = this.getExitUrl(layer);
|
||||||
if (exitUrl !== undefined) {
|
if (exitUrl !== undefined) {
|
||||||
this.loadNextGameFromExitUrl(exitUrl);
|
this.loadNextGameFromExitUrl(exitUrl).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layer.type === "objectgroup") {
|
if (layer.type === "objectgroup") {
|
||||||
@ -530,7 +532,7 @@ export class GameScene extends DirtyScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.gameMap.exitUrls.forEach((exitUrl) => {
|
this.gameMap.exitUrls.forEach((exitUrl) => {
|
||||||
this.loadNextGameFromExitUrl(exitUrl);
|
this.loadNextGameFromExitUrl(exitUrl).catch((e) => console.error(e));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.startPositionCalculator = new StartPositionCalculator(
|
this.startPositionCalculator = new StartPositionCalculator(
|
||||||
@ -551,7 +553,10 @@ export class GameScene extends DirtyScene {
|
|||||||
mediaManager.setUserInputManager(this.userInputManager);
|
mediaManager.setUserInputManager(this.userInputManager);
|
||||||
|
|
||||||
if (localUserStore.getFullscreen()) {
|
if (localUserStore.getFullscreen()) {
|
||||||
document.querySelector("body")?.requestFullscreen();
|
document
|
||||||
|
.querySelector("body")
|
||||||
|
?.requestFullscreen()
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
//notify game manager can to create currentUser in map
|
//notify game manager can to create currentUser in map
|
||||||
@ -657,9 +662,16 @@ export class GameScene extends DirtyScene {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all([this.connectionAnswerPromise as Promise<unknown>, ...scriptPromises]).then(() => {
|
Promise.all([this.connectionAnswerPromise as Promise<unknown>, ...scriptPromises])
|
||||||
this.scene.wake();
|
.then(() => {
|
||||||
});
|
this.scene.wake();
|
||||||
|
})
|
||||||
|
.catch((e) =>
|
||||||
|
console.error(
|
||||||
|
"Some scripts failed to load ot the connection failed to establish to WorkAdventure server",
|
||||||
|
e
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -859,7 +871,8 @@ export class GameScene extends DirtyScene {
|
|||||||
// iframeListener.sendLeaveLayerEvent(layer.name);
|
// iframeListener.sendLeaveLayerEvent(layer.name);
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
});
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: into dedicated classes
|
//todo: into dedicated classes
|
||||||
@ -912,7 +925,7 @@ export class GameScene extends DirtyScene {
|
|||||||
if (newValue) {
|
if (newValue) {
|
||||||
this.onMapExit(
|
this.onMapExit(
|
||||||
Room.getRoomPathFromExitSceneUrl(newValue as string, window.location.toString(), this.MapUrlFile)
|
Room.getRoomPathFromExitSceneUrl(newValue as string, window.location.toString(), this.MapUrlFile)
|
||||||
);
|
).catch((e) => console.error(e));
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
layoutManagerActionStore.removeAction("roomAccessDenied");
|
layoutManagerActionStore.removeAction("roomAccessDenied");
|
||||||
@ -921,7 +934,9 @@ export class GameScene extends DirtyScene {
|
|||||||
});
|
});
|
||||||
this.gameMap.onPropertyChange(GameMapProperties.EXIT_URL, (newValue, oldValue) => {
|
this.gameMap.onPropertyChange(GameMapProperties.EXIT_URL, (newValue, oldValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
this.onMapExit(Room.getRoomPathFromExitUrl(newValue as string, window.location.toString()));
|
this.onMapExit(Room.getRoomPathFromExitUrl(newValue as string, window.location.toString())).catch((e) =>
|
||||||
|
console.error(e)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
layoutManagerActionStore.removeAction("roomAccessDenied");
|
layoutManagerActionStore.removeAction("roomAccessDenied");
|
||||||
@ -1107,7 +1122,9 @@ ${escapedMessage}
|
|||||||
this.iframeSubscriptionList.push(
|
this.iframeSubscriptionList.push(
|
||||||
iframeListener.playSoundStream.subscribe((playSoundEvent) => {
|
iframeListener.playSoundStream.subscribe((playSoundEvent) => {
|
||||||
const url = new URL(playSoundEvent.url, this.MapUrlFile);
|
const url = new URL(playSoundEvent.url, this.MapUrlFile);
|
||||||
soundManager.playSound(this.load, this.sound, url.toString(), playSoundEvent.config);
|
soundManager
|
||||||
|
.playSound(this.load, this.sound, url.toString(), playSoundEvent.config)
|
||||||
|
.catch((e) => console.error(e));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1145,7 +1162,7 @@ ${escapedMessage}
|
|||||||
this.iframeSubscriptionList.push(
|
this.iframeSubscriptionList.push(
|
||||||
iframeListener.loadSoundStream.subscribe((loadSoundEvent) => {
|
iframeListener.loadSoundStream.subscribe((loadSoundEvent) => {
|
||||||
const url = new URL(loadSoundEvent.url, this.MapUrlFile);
|
const url = new URL(loadSoundEvent.url, this.MapUrlFile);
|
||||||
soundManager.loadSound(this.load, this.sound, url.toString());
|
soundManager.loadSound(this.load, this.sound, url.toString()).catch((e) => console.error(e));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1156,11 +1173,15 @@ ${escapedMessage}
|
|||||||
);
|
);
|
||||||
this.iframeSubscriptionList.push(
|
this.iframeSubscriptionList.push(
|
||||||
iframeListener.loadPageStream.subscribe((url: string) => {
|
iframeListener.loadPageStream.subscribe((url: string) => {
|
||||||
this.loadNextGameFromExitUrl(url).then(() => {
|
this.loadNextGameFromExitUrl(url)
|
||||||
this.events.once(EVENT_TYPE.POST_UPDATE, () => {
|
.then(() => {
|
||||||
this.onMapExit(Room.getRoomPathFromExitUrl(url, window.location.toString()));
|
this.events.once(EVENT_TYPE.POST_UPDATE, () => {
|
||||||
});
|
this.onMapExit(Room.getRoomPathFromExitUrl(url, window.location.toString())).catch((e) =>
|
||||||
});
|
console.error(e)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
let scriptedBubbleSprite: Sprite;
|
let scriptedBubbleSprite: Sprite;
|
||||||
@ -1417,7 +1438,7 @@ ${escapedMessage}
|
|||||||
propertyValue: string | number | boolean | undefined
|
propertyValue: string | number | boolean | undefined
|
||||||
): void {
|
): void {
|
||||||
if (propertyName === GameMapProperties.EXIT_URL && typeof propertyValue === "string") {
|
if (propertyName === GameMapProperties.EXIT_URL && typeof propertyValue === "string") {
|
||||||
this.loadNextGameFromExitUrl(propertyValue);
|
this.loadNextGameFromExitUrl(propertyValue).catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
this.gameMap.setLayerProperty(layerName, propertyName, propertyValue);
|
this.gameMap.setLayerProperty(layerName, propertyName, propertyValue);
|
||||||
}
|
}
|
||||||
@ -1502,7 +1523,7 @@ ${escapedMessage}
|
|||||||
|
|
||||||
public cleanupClosingScene(): void {
|
public cleanupClosingScene(): void {
|
||||||
// stop playing audio, close any open website, stop any open Jitsi
|
// stop playing audio, close any open website, stop any open Jitsi
|
||||||
coWebsiteManager.closeCoWebsites();
|
coWebsiteManager.closeCoWebsites().catch((e) => console.error(e));
|
||||||
// Stop the script, if any
|
// Stop the script, if any
|
||||||
const scripts = this.getScriptUrls(this.mapFile);
|
const scripts = this.getScriptUrls(this.mapFile);
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
@ -2044,7 +2065,9 @@ ${escapedMessage}
|
|||||||
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
|
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
|
||||||
const jitsiWidth = allProps.get(GameMapProperties.JITSI_WIDTH) as number | undefined;
|
const jitsiWidth = allProps.get(GameMapProperties.JITSI_WIDTH) as number | undefined;
|
||||||
|
|
||||||
jitsiFactory.start(roomName, this.playerName, jwt, jitsiConfig, jitsiInterfaceConfig, jitsiUrl, jitsiWidth);
|
jitsiFactory
|
||||||
|
.start(roomName, this.playerName, jwt, jitsiConfig, jitsiInterfaceConfig, jitsiUrl, jitsiWidth)
|
||||||
|
.catch((e) => console.error(e));
|
||||||
this.connection?.setSilent(true);
|
this.connection?.setSilent(true);
|
||||||
mediaManager.hideGameOverlay();
|
mediaManager.hideGameOverlay();
|
||||||
analyticsClient.enteredJitsi(roomName, this.room.id);
|
analyticsClient.enteredJitsi(roomName, this.room.id);
|
||||||
|
@ -40,19 +40,21 @@ export class CustomizeScene extends AbstractCharacterScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preload() {
|
preload() {
|
||||||
this.loadCustomSceneSelectCharacters().then((bodyResourceDescriptions) => {
|
this.loadCustomSceneSelectCharacters()
|
||||||
bodyResourceDescriptions.forEach((bodyResourceDescription) => {
|
.then((bodyResourceDescriptions) => {
|
||||||
if (
|
bodyResourceDescriptions.forEach((bodyResourceDescription) => {
|
||||||
bodyResourceDescription.level == undefined ||
|
if (
|
||||||
bodyResourceDescription.level < 0 ||
|
bodyResourceDescription.level == undefined ||
|
||||||
bodyResourceDescription.level > 5
|
bodyResourceDescription.level < 0 ||
|
||||||
) {
|
bodyResourceDescription.level > 5
|
||||||
throw "Texture level is null";
|
) {
|
||||||
}
|
throw "Texture level is null";
|
||||||
this.layers[bodyResourceDescription.level].unshift(bodyResourceDescription);
|
}
|
||||||
});
|
this.layers[bodyResourceDescription.level].unshift(bodyResourceDescription);
|
||||||
this.lazyloadingAttempt = true;
|
});
|
||||||
});
|
this.lazyloadingAttempt = true;
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
|
|
||||||
this.layers = loadAllLayers(this.load);
|
this.layers = loadAllLayers(this.load);
|
||||||
this.lazyloadingAttempt = false;
|
this.lazyloadingAttempt = false;
|
||||||
|
@ -41,12 +41,14 @@ export class SelectCharacterScene extends AbstractCharacterScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preload() {
|
preload() {
|
||||||
this.loadSelectSceneCharacters().then((bodyResourceDescriptions) => {
|
this.loadSelectSceneCharacters()
|
||||||
bodyResourceDescriptions.forEach((bodyResourceDescription) => {
|
.then((bodyResourceDescriptions) => {
|
||||||
this.playerModels.push(bodyResourceDescription);
|
bodyResourceDescriptions.forEach((bodyResourceDescription) => {
|
||||||
});
|
this.playerModels.push(bodyResourceDescription);
|
||||||
this.lazyloadingAttempt = true;
|
});
|
||||||
});
|
this.lazyloadingAttempt = true;
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
this.playerModels = loadAllDefaultModels(this.load);
|
this.playerModels = loadAllDefaultModels(this.load);
|
||||||
this.lazyloadingAttempt = false;
|
this.lazyloadingAttempt = false;
|
||||||
|
|
||||||
|
@ -360,32 +360,27 @@ const implementCorrectTrackBehavior = getNavigatorType() === NavigatorType.firef
|
|||||||
/**
|
/**
|
||||||
* Stops the camera from filming
|
* Stops the camera from filming
|
||||||
*/
|
*/
|
||||||
function applyCameraConstraints(currentStream: MediaStream | null, constraints: MediaTrackConstraints | boolean): void {
|
async function applyCameraConstraints(
|
||||||
|
currentStream: MediaStream | null,
|
||||||
|
constraints: MediaTrackConstraints | boolean
|
||||||
|
): Promise<void[]> {
|
||||||
if (!currentStream) {
|
if (!currentStream) {
|
||||||
return;
|
return [];
|
||||||
}
|
|
||||||
for (const track of currentStream.getVideoTracks()) {
|
|
||||||
toggleConstraints(track, constraints).catch((e) =>
|
|
||||||
console.error("Error while setting new camera constraints:", e)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return Promise.all(currentStream.getVideoTracks().map((track) => toggleConstraints(track, constraints)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops the microphone from listening
|
* Stops the microphone from listening
|
||||||
*/
|
*/
|
||||||
function applyMicrophoneConstraints(
|
async function applyMicrophoneConstraints(
|
||||||
currentStream: MediaStream | null,
|
currentStream: MediaStream | null,
|
||||||
constraints: MediaTrackConstraints | boolean
|
constraints: MediaTrackConstraints | boolean
|
||||||
): void {
|
): Promise<void[]> {
|
||||||
if (!currentStream) {
|
if (!currentStream) {
|
||||||
return;
|
return [];
|
||||||
}
|
|
||||||
for (const track of currentStream.getAudioTracks()) {
|
|
||||||
toggleConstraints(track, constraints).catch((e) =>
|
|
||||||
console.error("Error while setting new audio constraints:", e)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return Promise.all(currentStream.getAudioTracks().map((track) => toggleConstraints(track, constraints)));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleConstraints(track: MediaStreamTrack, constraints: MediaTrackConstraints | boolean): Promise<void> {
|
async function toggleConstraints(track: MediaStreamTrack, constraints: MediaTrackConstraints | boolean): Promise<void> {
|
||||||
@ -477,8 +472,8 @@ export const localStreamStore = derived<Readable<MediaStreamConstraints>, LocalS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyMicrophoneConstraints(currentStream, constraints.audio || false);
|
applyMicrophoneConstraints(currentStream, constraints.audio || false).catch((e) => console.error(e));
|
||||||
applyCameraConstraints(currentStream, constraints.video || false);
|
applyCameraConstraints(currentStream, constraints.video || false).catch((e) => console.error(e));
|
||||||
|
|
||||||
if (implementCorrectTrackBehavior) {
|
if (implementCorrectTrackBehavior) {
|
||||||
//on good navigators like firefox, we can instantiate the stream once and simply disable or enable the tracks as needed
|
//on good navigators like firefox, we can instantiate the stream once and simply disable or enable the tracks as needed
|
||||||
|
@ -156,7 +156,7 @@ export const screenSharingLocalStreamStore = derived<Readable<MediaStreamConstra
|
|||||||
error: e instanceof Error ? e : new Error("An unknown error happened"),
|
error: e instanceof Error ? e : new Error("An unknown error happened"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})().catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class UrlManager {
|
|||||||
if (window.location.pathname === room.id) return;
|
if (window.location.pathname === room.id) return;
|
||||||
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
|
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
|
||||||
//use href to keep # value
|
//use href to keep # value
|
||||||
localUserStore.setLastRoomUrl(room.href);
|
localUserStore.setLastRoomUrl(room.href).catch((e) => console.error(e));
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
const search = room.search.toString();
|
const search = room.search.toString();
|
||||||
history.pushState({}, "WorkAdventure", room.id + (search ? "?" + search : "") + hash);
|
history.pushState({}, "WorkAdventure", room.id + (search ? "?" + search : "") + hash);
|
||||||
|
@ -149,7 +149,7 @@ class CoWebsiteManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buttonCloseCoWebsites.blur();
|
buttonCloseCoWebsites.blur();
|
||||||
this.closeCoWebsites();
|
this.closeCoWebsites().catch((e) => console.error(e));
|
||||||
});
|
});
|
||||||
|
|
||||||
const buttonFullScreenFrame = HtmlUtils.getElementByIdOrFail(cowebsiteFullScreenButtonId);
|
const buttonFullScreenFrame = HtmlUtils.getElementByIdOrFail(cowebsiteFullScreenButtonId);
|
||||||
@ -515,70 +515,72 @@ class CoWebsiteManager {
|
|||||||
throw new Error("Too many we");
|
throw new Error("Too many we");
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.resolve(callback(this.cowebsiteBufferDom)).then((iframe) => {
|
Promise.resolve(callback(this.cowebsiteBufferDom))
|
||||||
iframe?.classList.add("pixel");
|
.then((iframe) => {
|
||||||
|
iframe?.classList.add("pixel");
|
||||||
|
|
||||||
if (!iframe.id) {
|
if (!iframe.id) {
|
||||||
do {
|
do {
|
||||||
iframe.id = "cowebsite-iframe-" + (Math.random() + 1).toString(36).substring(7);
|
iframe.id = "cowebsite-iframe-" + (Math.random() + 1).toString(36).substring(7);
|
||||||
} while (this.getCoWebsiteById(iframe.id));
|
} while (this.getCoWebsiteById(iframe.id));
|
||||||
}
|
|
||||||
|
|
||||||
const onloadPromise = new Promise<void>((resolve) => {
|
|
||||||
iframe.onload = () => resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
const icon = this.generateCoWebsiteIcon(iframe);
|
|
||||||
|
|
||||||
const coWebsite = {
|
|
||||||
iframe,
|
|
||||||
icon,
|
|
||||||
position: position ?? this.coWebsites.length,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Iframe management on mobile
|
|
||||||
icon.addEventListener("click", () => {
|
|
||||||
if (this.isSmallScreen()) {
|
|
||||||
this.moveRightPreviousCoWebsite(coWebsite, 0);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
this.coWebsites.push(coWebsite);
|
const onloadPromise = new Promise<void>((resolve) => {
|
||||||
this.cowebsiteSubIconsDom.appendChild(icon);
|
iframe.onload = () => resolve();
|
||||||
|
});
|
||||||
|
|
||||||
const onTimeoutPromise = new Promise<void>((resolve) => {
|
const icon = this.generateCoWebsiteIcon(iframe);
|
||||||
setTimeout(() => resolve(), 2000);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.currentOperationPromise = this.currentOperationPromise
|
const coWebsite = {
|
||||||
.then(() => Promise.race([onloadPromise, onTimeoutPromise]))
|
iframe,
|
||||||
.then(() => {
|
icon,
|
||||||
if (coWebsite.position === 0) {
|
position: position ?? this.coWebsites.length,
|
||||||
this.openMain();
|
};
|
||||||
if (widthPercent) {
|
|
||||||
this.widthPercent = widthPercent;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => {
|
// Iframe management on mobile
|
||||||
this.fire();
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.currentOperationPromise = this.currentOperationPromise
|
||||||
|
.then(() => Promise.race([onloadPromise, onTimeoutPromise]))
|
||||||
|
.then(() => {
|
||||||
|
if (coWebsite.position === 0) {
|
||||||
|
this.openMain();
|
||||||
|
if (widthPercent) {
|
||||||
|
this.widthPercent = widthPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.fire();
|
||||||
|
position !== undefined
|
||||||
|
? this.moveRightPreviousCoWebsite(coWebsite, coWebsite.position)
|
||||||
|
: this.moveCoWebsite(coWebsite, coWebsite.position);
|
||||||
|
}, animationTime);
|
||||||
|
} else {
|
||||||
position !== undefined
|
position !== undefined
|
||||||
? this.moveRightPreviousCoWebsite(coWebsite, coWebsite.position)
|
? this.moveRightPreviousCoWebsite(coWebsite, coWebsite.position)
|
||||||
: this.moveCoWebsite(coWebsite, coWebsite.position);
|
: this.moveCoWebsite(coWebsite, coWebsite.position);
|
||||||
}, animationTime);
|
}
|
||||||
} else {
|
|
||||||
position !== undefined
|
|
||||||
? this.moveRightPreviousCoWebsite(coWebsite, coWebsite.position)
|
|
||||||
: this.moveCoWebsite(coWebsite, coWebsite.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolve(coWebsite);
|
return resolve(coWebsite);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Error loadCoWebsite => ", err);
|
console.error("Error loadCoWebsite => ", err);
|
||||||
this.removeCoWebsiteFromStack(coWebsite);
|
this.removeCoWebsiteFromStack(coWebsite);
|
||||||
return reject();
|
return reject();
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
.catch((e) => console.error("Error loadCoWebsite >=> ", e));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,17 +605,21 @@ class CoWebsiteManager {
|
|||||||
return this.currentOperationPromise;
|
return this.currentOperationPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeJitsi() {
|
public async closeJitsi() {
|
||||||
const jitsi = this.searchJitsi();
|
const jitsi = this.searchJitsi();
|
||||||
if (jitsi) {
|
if (jitsi) {
|
||||||
this.closeCoWebsite(jitsi);
|
return this.closeCoWebsite(jitsi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeCoWebsites(): Promise<void> {
|
public closeCoWebsites(): Promise<void> {
|
||||||
this.currentOperationPromise = this.currentOperationPromise.then(() => {
|
this.currentOperationPromise = this.currentOperationPromise.then(() => {
|
||||||
|
const promises: Promise<void>[] = [];
|
||||||
this.coWebsites.forEach((coWebsite: CoWebsite) => {
|
this.coWebsites.forEach((coWebsite: CoWebsite) => {
|
||||||
this.closeCoWebsite(coWebsite);
|
promises.push(this.closeCoWebsite(coWebsite));
|
||||||
|
});
|
||||||
|
return Promise.all(promises).then(() => {
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return this.currentOperationPromise;
|
return this.currentOperationPromise;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { JITSI_URL } from "../Enum/EnvironmentVariable";
|
import { JITSI_URL } from "../Enum/EnvironmentVariable";
|
||||||
import { coWebsiteManager } from "./CoWebsiteManager";
|
import { CoWebsite, coWebsiteManager } from "./CoWebsiteManager";
|
||||||
import { requestedCameraState, requestedMicrophoneState } from "../Stores/MediaStore";
|
import { requestedCameraState, requestedMicrophoneState } from "../Stores/MediaStore";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ class JitsiFactory {
|
|||||||
interfaceConfig?: object,
|
interfaceConfig?: object,
|
||||||
jitsiUrl?: string,
|
jitsiUrl?: string,
|
||||||
jitsiWidth?: number
|
jitsiWidth?: number
|
||||||
): void {
|
): Promise<CoWebsite> {
|
||||||
coWebsiteManager.addCoWebsite(
|
return coWebsiteManager.addCoWebsite(
|
||||||
async (cowebsiteDiv) => {
|
async (cowebsiteDiv) => {
|
||||||
// Jitsi meet external API maintains some data in local storage
|
// Jitsi meet external API maintains some data in local storage
|
||||||
// which is sent via the appData URL parameter when joining a
|
// which is sent via the appData URL parameter when joining a
|
||||||
@ -200,7 +200,7 @@ class JitsiFactory {
|
|||||||
const jitsiCoWebsite = coWebsiteManager.searchJitsi();
|
const jitsiCoWebsite = coWebsiteManager.searchJitsi();
|
||||||
|
|
||||||
if (jitsiCoWebsite) {
|
if (jitsiCoWebsite) {
|
||||||
coWebsiteManager.closeJitsi();
|
coWebsiteManager.closeJitsi().catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.jitsiApi.removeListener("audioMuteStatusChanged", this.audioCallback);
|
this.jitsiApi.removeListener("audioMuteStatusChanged", this.audioCallback);
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
} from "./Api/Events/IframeEvent";
|
} from "./Api/Events/IframeEvent";
|
||||||
import chat from "./Api/iframe/chat";
|
import chat from "./Api/iframe/chat";
|
||||||
import type { IframeCallback } from "./Api/iframe/IframeApiContribution";
|
import type { IframeCallback } from "./Api/iframe/IframeApiContribution";
|
||||||
import nav from "./Api/iframe/nav";
|
import nav, { CoWebsite } from "./Api/iframe/nav";
|
||||||
import controls from "./Api/iframe/controls";
|
import controls from "./Api/iframe/controls";
|
||||||
import ui from "./Api/iframe/ui";
|
import ui from "./Api/iframe/ui";
|
||||||
import sound from "./Api/iframe/sound";
|
import sound from "./Api/iframe/sound";
|
||||||
@ -136,17 +136,17 @@ const wa = {
|
|||||||
/**
|
/**
|
||||||
* @deprecated Use WA.nav.openCoWebSite instead
|
* @deprecated Use WA.nav.openCoWebSite instead
|
||||||
*/
|
*/
|
||||||
openCoWebSite(url: string, allowApi: boolean = false, allowPolicy: string = ""): void {
|
openCoWebSite(url: string, allowApi: boolean = false, allowPolicy: string = ""): Promise<CoWebsite> {
|
||||||
console.warn("Method WA.openCoWebSite is deprecated. Please use WA.nav.openCoWebSite instead");
|
console.warn("Method WA.openCoWebSite is deprecated. Please use WA.nav.openCoWebSite instead");
|
||||||
nav.openCoWebSite(url, allowApi, allowPolicy);
|
return nav.openCoWebSite(url, allowApi, allowPolicy);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use WA.nav.closeCoWebSite instead
|
* @deprecated Use WA.nav.closeCoWebSite instead
|
||||||
*/
|
*/
|
||||||
closeCoWebSite(): void {
|
closeCoWebSite(): Promise<void> {
|
||||||
console.warn("Method WA.closeCoWebSite is deprecated. Please use WA.nav.closeCoWebSite instead");
|
console.warn("Method WA.closeCoWebSite is deprecated. Please use WA.nav.closeCoWebSite instead");
|
||||||
nav.closeCoWebSite();
|
return nav.closeCoWebSite();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user