From 65785240e1ec751307e786fe0d5c1a110fdb49e9 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Wed, 25 Nov 2020 17:17:48 +0100 Subject: [PATCH] FIX: room id is now pushed to the url --- front/src/Phaser/Game/GameScene.ts | 1 + front/src/Url/UrlManager.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 4d6a0be1..7241ae14 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -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 diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index 18122889..bed26240 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -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;