From b0bc0bc56611128753e6a7cb5b000b6ba8ef7a3e Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 5 Jan 2024 14:40:29 +0600 Subject: [PATCH] UBERF-4807 (#4307) Signed-off-by: Denis Bykhov --- plugins/workbench-resources/src/connect.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/workbench-resources/src/connect.ts b/plugins/workbench-resources/src/connect.ts index 5e36d0d5c4..550b7d1c8c 100644 --- a/plugins/workbench-resources/src/connect.ts +++ b/plugins/workbench-resources/src/connect.ts @@ -14,6 +14,7 @@ import presentation, { closeClient, refreshClient, setClient } from '@hcengineer import { fetchMetadataLocalStorage, getCurrentLocation, + locationStorageKeyId, navigate, networkStatus, setMetadataLocalStorage @@ -33,7 +34,21 @@ addEventListener(client.event.NetworkRequests, async (event: string, val: number export async function connect (title: string): Promise { const loc = getCurrentLocation() const ws = loc.path[1] - if (ws === undefined) return + if (ws === undefined) { + const lastLoc = localStorage.getItem(locationStorageKeyId) + if (lastLoc !== null) { + const lastLocObj = JSON.parse(lastLoc) + if (lastLocObj.path !== undefined && lastLocObj.path[0] === loc.path[0]) { + navigate(lastLocObj) + return + } + } else { + navigate({ + path: [loginId] + }) + return + } + } const tokens: Record = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {} const token = tokens[ws] setMetadata(presentation.metadata.Token, token)