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 21:07:56 +07:00
committed by GitHub
parent 5d84053685
commit 602b23acd1
5 changed files with 19 additions and 3 deletions
@@ -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 {
+1
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)
}
+6 -1
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]> {
@@ -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] })
}
}
}
@@ -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