mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Remember last page (#2014)
igned-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
6137f0df2e
commit
d4b9353d29
@ -27,11 +27,16 @@
|
||||
}
|
||||
|
||||
if (application === undefined) {
|
||||
application = getMetadata(uiPlugin.metadata.DefaultApplication)
|
||||
if (application !== undefined) {
|
||||
const loc = getCurrentLocation()
|
||||
loc.path = [application]
|
||||
navigate(loc)
|
||||
const last = localStorage.getItem('platform_last_loc')
|
||||
if (last !== null) {
|
||||
navigate(JSON.parse(last))
|
||||
} else {
|
||||
application = getMetadata(uiPlugin.metadata.DefaultApplication)
|
||||
if (application !== undefined) {
|
||||
const loc = getCurrentLocation()
|
||||
loc.path = [application]
|
||||
navigate(loc)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -113,6 +113,7 @@ export function navigate (location: PlatformLocation): void {
|
||||
const url = locationToUrl(location)
|
||||
if (locationToUrl(getCurrentLocation()) !== url) {
|
||||
history.pushState(null, '', url)
|
||||
localStorage.setItem('platform_last_loc', JSON.stringify(location))
|
||||
locationWritable.set(location)
|
||||
}
|
||||
}
|
||||
|
@ -130,12 +130,20 @@
|
||||
|
||||
async function syncLoc (loc: Location): Promise<void> {
|
||||
const app = loc.path.length > 0 ? (loc.path[1] as Ref<Application>) : undefined
|
||||
const space = loc.path.length > 1 ? (loc.path[2] as Ref<Space>) : undefined
|
||||
const special = loc.path.length > 2 ? loc.path[3] : undefined
|
||||
let space = loc.path.length > 1 ? (loc.path[2] as Ref<Space>) : undefined
|
||||
let special = loc.path.length > 2 ? loc.path[3] : undefined
|
||||
|
||||
if (currentApp !== app) {
|
||||
clear(1)
|
||||
currentApp = app
|
||||
if (space === undefined) {
|
||||
const last = localStorage.getItem(`platform_last_loc_${currentApp}`)
|
||||
if (last !== null) {
|
||||
const newLocation: Location = JSON.parse(last)
|
||||
loc.path[2] = space = newLocation.path[2] as Ref<Space>
|
||||
loc.path[3] = special = newLocation.path[3]
|
||||
}
|
||||
}
|
||||
currentApplication = await client.findOne(workbench.class.Application, { _id: currentApp })
|
||||
navigatorModel = currentApplication?.navigatorModel
|
||||
}
|
||||
@ -151,6 +159,9 @@
|
||||
setSpaceSpecial(special)
|
||||
}
|
||||
}
|
||||
if (app !== undefined) {
|
||||
localStorage.setItem(`platform_last_loc_${currentApp}`, JSON.stringify(loc))
|
||||
}
|
||||
}
|
||||
|
||||
function clear (level: number): void {
|
||||
|
Loading…
Reference in New Issue
Block a user