TSK-811: Show last workspace location after switching/opening workspace (#2776)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-03-20 19:07:56 +05:00 committed by GitHub
parent 5d84053685
commit 602b23acd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 3 deletions

View File

@ -35,7 +35,7 @@
}
if (application === undefined) {
const last = localStorage.getItem('platform_last_loc')
const last = localStorage.getItem(`platform_last_loc_${loc.path[1]}`)
if (last !== null) {
navigate(JSON.parse(last))
} else {

View File

@ -115,6 +115,7 @@ export function navigate (location: PlatformLocation, store = true): void {
if (store) {
history.pushState(null, '', url)
localStorage.setItem('platform_last_loc', JSON.stringify(location))
localStorage.setItem(`platform_last_loc_${location.path[1]}`, JSON.stringify(location))
}
locationWritable.set(location)
}

View File

@ -302,7 +302,12 @@ export function navigateToWorkspace (workspace: string, loginInfo?: WorkspaceLog
// Json parse error could be ignored
}
}
navigate({ path: [workbenchId, workspace] })
const last = localStorage.getItem(`platform_last_loc_${workspace}`)
if (last !== null) {
navigate(JSON.parse(last))
} else {
navigate({ path: [workbenchId, workspace] })
}
}
export async function checkJoined (inviteId: string): Promise<[Status, WorkspaceLoginInfo | undefined]> {

View File

@ -71,7 +71,10 @@
closePopup()
closePopup()
if (ws !== getCurrentLocation().path[1]) {
navigate({ path: [workbenchId, ws] })
const last = localStorage.getItem(`platform_last_loc_${ws}`)
if (last !== null) {
navigate(JSON.parse(last))
} else navigate({ path: [workbenchId, ws] })
}
}
}

View File

@ -260,6 +260,13 @@
let special = loc.path[4]
const fragment = loc.fragment
if (app === undefined) {
const last = localStorage.getItem(`platform_last_loc_${loc.path[1]}`)
if (last != null) {
navigate(JSON.parse(last))
}
}
if (currentAppAlias !== app) {
clear(1)
currentAppAlias = app