Merge pull request #1718 from thecodingmachine/master

Hot fixes
This commit is contained in:
Alexis Faizeau 2022-01-12 10:47:27 +01:00 committed by GitHub
commit 3f3f488924
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 54 additions and 42 deletions

View file

@ -106,10 +106,10 @@ class ConnectionManager {
const code = urlParams.get("code");
const state = urlParams.get("state");
if (!state || !localUserStore.verifyState(state)) {
throw "Could not validate state!";
throw new Error("Could not validate state!");
}
if (!code) {
throw "No Auth code provided";
throw new Error("No Auth code provided");
}
localUserStore.setCode(code);
}
@ -168,6 +168,9 @@ class ConnectionManager {
}
} catch (err) {
console.error(err);
if (err instanceof Error) {
console.error(err.stack);
}
}
} else {
const query = urlParams.toString();
@ -333,10 +336,10 @@ class ConnectionManager {
if (!token) {
if (!state || !localUserStore.verifyState(state)) {
throw "Could not validate state!";
throw new Error("Could not validate state!");
}
if (!code) {
throw "No Auth code provided";
throw new Error("No Auth code provided");
}
}
const { authToken, userUuid, textures, email } = await Axios.get(`${PUSHER_URL}/login-callback`, {

View file

@ -139,9 +139,13 @@ class LocalUserStore {
async setLastRoomUrl(roomUrl: string): Promise<void> {
localStorage.setItem(lastRoomUrl, roomUrl.toString());
if ("caches" in window) {
const cache = await caches.open(cacheAPIIndex);
const stringResponse = new Response(JSON.stringify({ roomUrl }));
await cache.put(`/${lastRoomUrl}`, stringResponse);
try {
const cache = await caches.open(cacheAPIIndex);
const stringResponse = new Response(JSON.stringify({ roomUrl }));
await cache.put(`/${lastRoomUrl}`, stringResponse);
} catch (e) {
console.error("Could not store last room url in Browser cache. Are you using private browser mode?", e);
}
}
}
getLastRoomUrl(): string {

View file

@ -691,7 +691,7 @@ export class RoomConnection implements RoomConnection {
}
public getUserId(): number {
if (this.userId === null) throw "UserId cannot be null!";
if (this.userId === null) throw new Error("UserId cannot be null!");
return this.userId;
}