merge latest dev

This commit is contained in:
_Bastler
2021-11-24 13:00:27 +01:00
parent 1873ac1836
commit 3b98888c3a
26 changed files with 9451 additions and 64 deletions
+21 -33
View File
@@ -4,7 +4,7 @@ declare let window: any;
class AnalyticsClient {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private posthogPromise: Promise<any>;
private posthogPromise: Promise<any>|undefined;
constructor() {
if (POSTHOG_API_KEY && POSTHOG_URL) {
@@ -14,90 +14,78 @@ class AnalyticsClient {
window.posthog = posthog;
return posthog;
});
} else {
this.posthogPromise = Promise.reject();
}
}
identifyUser(uuid: string, email: string | null) {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.identify(uuid, { uuid, email, wa: true });
})
.catch();
});
}
loggedWithSso() {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-logged-sso");
})
.catch();
});
}
loggedWithToken() {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-logged-token");
})
.catch();
});
}
enteredRoom(roomId: string, roomGroup: string | null) {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("$pageView", { roomId, roomGroup });
posthog.capture("enteredRoom");
})
.catch();
});
}
openedMenu() {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-opened-menu");
})
.catch();
});
}
launchEmote(emote: string) {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-emote-launch", { emote });
})
.catch();
});
}
enteredJitsi(roomName: string, roomId: string) {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-entered-jitsi", { roomName, roomId });
})
.catch();
});
}
validationName() {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-name-validation");
})
.catch();
});
}
validationWoka(scene: string) {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-woka-validation", { scene });
})
.catch();
});
}
validationVideo() {
this.posthogPromise
.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-video-validation");
})
.catch();
});
}
}
export const analyticsClient = new AnalyticsClient();
+3 -2
View File
@@ -321,8 +321,9 @@ class ConnectionManager {
this.localUser = new LocalUser(userUuid, textures, email);
localUserStore.saveUser(this.localUser);
this.authToken = authToken;
gameManager.setPlayerName(username);
if (username) {
gameManager.setPlayerName(username);
}
//user connected, set connected store for menu at true
userIsConnected.set(true);
}
+9 -4
View File
@@ -122,10 +122,12 @@ class LocalUserStore {
setLastRoomUrl(roomUrl: string): void {
localStorage.setItem(lastRoomUrl, roomUrl.toString());
caches.open(cacheAPIIndex).then((cache) => {
const stringResponse = new Response(JSON.stringify({ roomUrl }));
cache.put(`/${lastRoomUrl}`, stringResponse);
});
if ('caches' in window) {
caches.open(cacheAPIIndex).then((cache) => {
const stringResponse = new Response(JSON.stringify({ roomUrl }));
cache.put(`/${lastRoomUrl}`, stringResponse);
});
}
}
getLastRoomUrl(): string {
return (
@@ -133,6 +135,9 @@ class LocalUserStore {
);
}
getLastRoomUrlCacheApi(): Promise<string | undefined> {
if (!('caches' in window)) {
return Promise.resolve(undefined);
}
return caches.open(cacheAPIIndex).then((cache) => {
return cache.match(`/${lastRoomUrl}`).then((res) => {
return res?.json().then((data) => {
@@ -162,6 +162,7 @@ export class EmbeddedWebsiteManager {
const iframe = document.createElement("iframe");
iframe.src = absoluteUrl;
iframe.tabIndex = -1;
iframe.style.width = embeddedWebsiteEvent.position.width + "px";
iframe.style.height = embeddedWebsiteEvent.position.height + "px";
iframe.style.margin = "0";
@@ -52,13 +52,15 @@ export class StartPositionCalculator {
if (!selectedOrDefaultLayer) {
selectedOrDefaultLayer = defaultStartLayerName;
}
selectedOrDefaultLayer = selectedOrDefaultLayer.replace('#','');
let foundLayer: ITiledMapLayer | null = null;
for (const layer of this.gameMap.flatLayers) {
if (layer.type !== "tilelayer") continue;
//we want to prioritize the selectedLayer other the start layer
if (
(selectedOrDefaultLayer === layer.name ||
selectedOrDefaultLayer === `#${layer.name}` ||
layer.name.endsWith("/" + selectedOrDefaultLayer)) &&
layer.type === "tilelayer" &&
(selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer))