UBERF-4807 (#4307)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-01-05 14:40:29 +06:00 committed by GitHub
parent acd80be4df
commit b0bc0bc566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<Client | undefined> {
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<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
const token = tokens[ws]
setMetadata(presentation.metadata.Token, token)