Simplifying code and making START_ROOM_URL compatible with public (_) and private (@) paths
This commit is contained in:
parent
d79a18ee81
commit
bbf9325396
@ -5,4 +5,4 @@ JITSI_PRIVATE_MODE=false
|
||||
JITSI_ISS=
|
||||
SECRET_JITSI_KEY=
|
||||
ADMIN_API_TOKEN=123
|
||||
START_ROOM_URL=/Floor0/floor0.json
|
||||
START_ROOM_URL=/_/global/maps.workadventure.localhost/Floor0/floor0.json
|
||||
|
@ -27,9 +27,9 @@ class ConnectionManager {
|
||||
const organizationSlug = data.organizationSlug;
|
||||
const worldSlug = data.worldSlug;
|
||||
const roomSlug = data.roomSlug;
|
||||
urlManager.editUrlForRoom(roomSlug, organizationSlug, worldSlug);
|
||||
|
||||
const room = new Room(window.location.pathname + window.location.hash);
|
||||
const room = new Room('/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug + window.location.hash);
|
||||
urlManager.pushRoomIdToUrl(room);
|
||||
return Promise.resolve(room);
|
||||
} else if (connexionType === GameConnexionTypes.organization || connexionType === GameConnexionTypes.anonymous || connexionType === GameConnexionTypes.empty) {
|
||||
const localUser = localUserStore.getLocalUser();
|
||||
@ -48,11 +48,7 @@ class ConnectionManager {
|
||||
}
|
||||
let roomId: string
|
||||
if (connexionType === GameConnexionTypes.empty) {
|
||||
if (START_ROOM_URL.startsWith('http://') || START_ROOM_URL.startsWith('https://')) {
|
||||
roomId = '/_/global/' + START_ROOM_URL.replace('http://', '').replace('https://', '');
|
||||
} else {
|
||||
roomId = urlManager.editUrlForRoom(START_ROOM_URL, null, null);
|
||||
}
|
||||
roomId = START_ROOM_URL;
|
||||
} else {
|
||||
roomId = window.location.pathname + window.location.hash;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
const DEBUG_MODE: boolean = process.env.DEBUG_MODE == "true";
|
||||
const START_ROOM_URL : string = process.env.START_ROOM_URL || 'tcm/workadventure/floor0';
|
||||
const START_ROOM_URL : string = process.env.START_ROOM_URL || '/_/global/maps.workadventure.localhost/Floor0/floor0.json';
|
||||
const API_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.API_URL || "pusher.workadventure.localhost");
|
||||
const UPLOADER_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.UPLOADER_URL || 'uploader.workadventure.localhost');
|
||||
const ADMIN_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.ADMIN_URL || "workadventure.localhost");
|
||||
|
@ -32,26 +32,12 @@ class UrlManager {
|
||||
return match ? match [1] : null;
|
||||
}
|
||||
|
||||
|
||||
//todo: simply use the roomId
|
||||
//todo: test this with cypress
|
||||
public editUrlForRoom(roomSlug: string, organizationSlug: string|null, worldSlug: string |null): string {
|
||||
let newUrl:string;
|
||||
if (organizationSlug) {
|
||||
newUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug;
|
||||
} else {
|
||||
newUrl = '/@/'+roomSlug;
|
||||
}
|
||||
history.pushState({}, 'WorkAdventure', newUrl);
|
||||
return newUrl;
|
||||
}
|
||||
|
||||
public pushRoomIdToUrl(room:Room): void {
|
||||
if (window.location.pathname === room.id) return;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user