From 7b13e45e19c05d212ee4eaa7a0f31f011bbfc11e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 13 Oct 2020 13:13:15 +0200 Subject: [PATCH] fix creating the rooms segment --- src/domain/navigation/index.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index 1a635293..eca2c95f 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -42,19 +42,21 @@ function allowsChild(parent, child) { } function roomsSegmentWithRoom(rooms, roomId, path) { - const room = path.get("room"); - let index = 0; - if (room) { - index = rooms.value.indexOf(room.value); - } else { + if(!rooms.value.includes(roomId)) { const emptyGridTile = path.get("empty-grid-tile"); + const oldRoom = path.get("room"); + let index = 0; if (emptyGridTile) { index = emptyGridTile.value; + } else if (oldRoom) { + index = rooms.value.indexOf(oldRoom.value); } - } - const newRooms = rooms.value.slice(); - newRooms[index] = roomId; - return new Segment("rooms", newRooms); + const roomIds = rooms.value.slice(); + roomIds[index] = roomId; + return new Segment("rooms", roomIds); + } else { + return rooms; + } } export function parseUrlPath(urlPath, currentNavPath) {