mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 16:27:22 +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) {
|
if (application === undefined) {
|
||||||
application = getMetadata(uiPlugin.metadata.DefaultApplication)
|
const last = localStorage.getItem('platform_last_loc')
|
||||||
if (application !== undefined) {
|
if (last !== null) {
|
||||||
const loc = getCurrentLocation()
|
navigate(JSON.parse(last))
|
||||||
loc.path = [application]
|
} else {
|
||||||
navigate(loc)
|
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)
|
const url = locationToUrl(location)
|
||||||
if (locationToUrl(getCurrentLocation()) !== url) {
|
if (locationToUrl(getCurrentLocation()) !== url) {
|
||||||
history.pushState(null, '', url)
|
history.pushState(null, '', url)
|
||||||
|
localStorage.setItem('platform_last_loc', JSON.stringify(location))
|
||||||
locationWritable.set(location)
|
locationWritable.set(location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,12 +130,20 @@
|
|||||||
|
|
||||||
async function syncLoc (loc: Location): Promise<void> {
|
async function syncLoc (loc: Location): Promise<void> {
|
||||||
const app = loc.path.length > 0 ? (loc.path[1] as Ref<Application>) : undefined
|
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
|
let space = loc.path.length > 1 ? (loc.path[2] as Ref<Space>) : undefined
|
||||||
const special = loc.path.length > 2 ? loc.path[3] : undefined
|
let special = loc.path.length > 2 ? loc.path[3] : undefined
|
||||||
|
|
||||||
if (currentApp !== app) {
|
if (currentApp !== app) {
|
||||||
clear(1)
|
clear(1)
|
||||||
currentApp = app
|
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 })
|
currentApplication = await client.findOne(workbench.class.Application, { _id: currentApp })
|
||||||
navigatorModel = currentApplication?.navigatorModel
|
navigatorModel = currentApplication?.navigatorModel
|
||||||
}
|
}
|
||||||
@ -151,6 +159,9 @@
|
|||||||
setSpaceSpecial(special)
|
setSpaceSpecial(special)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (app !== undefined) {
|
||||||
|
localStorage.setItem(`platform_last_loc_${currentApp}`, JSON.stringify(loc))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear (level: number): void {
|
function clear (level: number): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user