Merge pull request #459 from thecodingmachine/hotfix/pushRoomIDToUrl

FIX: room id is now pushed to the url
This commit is contained in:
Kharhamel 2020-11-25 17:53:45 +01:00 committed by GitHub
commit 5c18f22f1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -301,6 +301,7 @@ export class GameScene extends ResizableScene implements CenterListener {
//hook create scene
create(): void {
urlManager.pushRoomIdToUrl(this.room);
this.startLayerName = urlManager.getStartLayerNameFromUrl();
//initalise map

View File

@ -1,3 +1,4 @@
import {Room} from "../Connexion/Room";
export enum GameConnexionTypes {
anonymous=1,
@ -45,6 +46,12 @@ class UrlManager {
return newUrl;
}
public pushRoomIdToUrl(room:Room): void {
if (window.location.pathname === room.id) return;
const hash = window.location.hash;
history.pushState({}, 'WorkAdventure', room.id+hash);
}
public getStartLayerNameFromUrl(): string|null {
const hash = window.location.hash;
return hash.length > 1 ? hash.substring(1) : null;