forked from mystiq/hydrogen-web
fix creating the rooms segment
This commit is contained in:
parent
a360d0a2b9
commit
7b13e45e19
1 changed files with 11 additions and 9 deletions
|
@ -42,19 +42,21 @@ function allowsChild(parent, child) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function roomsSegmentWithRoom(rooms, roomId, path) {
|
function roomsSegmentWithRoom(rooms, roomId, path) {
|
||||||
const room = path.get("room");
|
if(!rooms.value.includes(roomId)) {
|
||||||
let index = 0;
|
|
||||||
if (room) {
|
|
||||||
index = rooms.value.indexOf(room.value);
|
|
||||||
} else {
|
|
||||||
const emptyGridTile = path.get("empty-grid-tile");
|
const emptyGridTile = path.get("empty-grid-tile");
|
||||||
|
const oldRoom = path.get("room");
|
||||||
|
let index = 0;
|
||||||
if (emptyGridTile) {
|
if (emptyGridTile) {
|
||||||
index = emptyGridTile.value;
|
index = emptyGridTile.value;
|
||||||
|
} else if (oldRoom) {
|
||||||
|
index = rooms.value.indexOf(oldRoom.value);
|
||||||
}
|
}
|
||||||
}
|
const roomIds = rooms.value.slice();
|
||||||
const newRooms = rooms.value.slice();
|
roomIds[index] = roomId;
|
||||||
newRooms[index] = roomId;
|
return new Segment("rooms", roomIds);
|
||||||
return new Segment("rooms", newRooms);
|
} else {
|
||||||
|
return rooms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseUrlPath(urlPath, currentNavPath) {
|
export function parseUrlPath(urlPath, currentNavPath) {
|
||||||
|
|
Loading…
Reference in a new issue