From a4bcb21a85afcfbc95b3cb8197c2db49d9f537e5 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 4 Jun 2021 12:43:03 +0530 Subject: [PATCH] Move details handling to separate function Signed-off-by: RMidhunSuresh --- src/domain/session/leftpanel/LeftPanelViewModel.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/domain/session/leftpanel/LeftPanelViewModel.js b/src/domain/session/leftpanel/LeftPanelViewModel.js index c1696d26..9f7b85ab 100644 --- a/src/domain/session/leftpanel/LeftPanelViewModel.js +++ b/src/domain/session/leftpanel/LeftPanelViewModel.js @@ -92,24 +92,24 @@ export class LeftPanelViewModel extends ViewModel { } } + _pathForDetails(path) { + const details = this.navigation.path.get("details"); + return details ? path.with(details) : path; + } + toggleGrid() { const room = this.navigation.path.get("room"); - const details = this.navigation.path.get("details"); let path = this.navigation.path.until("session"); if (this.gridEnabled) { if (room) { path = path.with(room); - if (details) { - path = path.with(details); - } + path = this._pathForDetails(path); } } else { if (room) { path = path.with(this.navigation.segment("rooms", [room.value])); path = path.with(room); - if (details) { - path = path.with(details); - } + path = this._pathForDetails(path); } else { path = path.with(this.navigation.segment("rooms", [])); path = path.with(this.navigation.segment("empty-grid-tile", 0));