mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 04:08:19 +00:00
UBER-513: Fix desktop app navigation (#3459)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
7e7e67632b
commit
70d78e50b3
@ -3,7 +3,7 @@
|
|||||||
import { onDestroy } from 'svelte'
|
import { onDestroy } from 'svelte'
|
||||||
import type { AnyComponent } from '../../types'
|
import type { AnyComponent } from '../../types'
|
||||||
// import { applicationShortcutKey } from '../../utils'
|
// import { applicationShortcutKey } from '../../utils'
|
||||||
import { getCurrentLocation, location, navigate } from '../../location'
|
import { getCurrentLocation, location, navigate, locationStorageKeyId } from '../../location'
|
||||||
|
|
||||||
import { Theme } from '@hcengineering/theme'
|
import { Theme } from '@hcengineering/theme'
|
||||||
import Component from '../Component.svelte'
|
import Component from '../Component.svelte'
|
||||||
@ -35,9 +35,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (application === undefined) {
|
if (application === undefined) {
|
||||||
let last = loc.path[1] !== undefined ? localStorage.getItem(`platform_last_loc_${loc.path[1]}`) : null
|
let last = loc.path[1] !== undefined ? localStorage.getItem(`${locationStorageKeyId}_${loc.path[1]}`) : null
|
||||||
if (last === null) {
|
if (last === null) {
|
||||||
last = localStorage.getItem('platform_last_loc')
|
last = localStorage.getItem(locationStorageKeyId)
|
||||||
}
|
}
|
||||||
let useDefault = true
|
let useDefault = true
|
||||||
if (last !== null) {
|
if (last !== null) {
|
||||||
|
@ -40,7 +40,7 @@ export type {
|
|||||||
|
|
||||||
export { themeStore } from '@hcengineering/theme'
|
export { themeStore } from '@hcengineering/theme'
|
||||||
// export { applicationShortcutKey } from './utils'
|
// export { applicationShortcutKey } from './utils'
|
||||||
export { getCurrentLocation, locationToUrl, navigate, location } from './location'
|
export { getCurrentLocation, locationToUrl, navigate, location, setLocationStorageKey } from './location'
|
||||||
|
|
||||||
export { default as EditBox } from './components/EditBox.svelte'
|
export { default as EditBox } from './components/EditBox.svelte'
|
||||||
export { default as Label } from './components/Label.svelte'
|
export { default as Label } from './components/Label.svelte'
|
||||||
|
@ -148,6 +148,15 @@ export function getCurrentLocation (): PlatformLocation {
|
|||||||
return getRawCurrentLocation()
|
return getRawCurrentLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export let locationStorageKeyId = 'platform_last_loc'
|
||||||
|
|
||||||
|
export function setLocationStorageKey (storageKey: string): void {
|
||||||
|
locationStorageKeyId = storageKey
|
||||||
|
}
|
||||||
|
|
||||||
export function navigate (location: PlatformLocation, store = true): boolean {
|
export function navigate (location: PlatformLocation, store = true): boolean {
|
||||||
closePopup()
|
closePopup()
|
||||||
const cur = locationToUrl(getCurrentLocation())
|
const cur = locationToUrl(getCurrentLocation())
|
||||||
@ -157,9 +166,9 @@ export function navigate (location: PlatformLocation, store = true): boolean {
|
|||||||
if (!embeddedPlatform) {
|
if (!embeddedPlatform) {
|
||||||
history.pushState(null, '', url)
|
history.pushState(null, '', url)
|
||||||
}
|
}
|
||||||
localStorage.setItem('platform_last_loc', JSON.stringify(location))
|
localStorage.setItem(locationStorageKeyId, JSON.stringify(location))
|
||||||
if (location.path[1] !== undefined) {
|
if (location.path[1] !== undefined) {
|
||||||
localStorage.setItem(`platform_last_loc_${location.path[1]}`, JSON.stringify(location))
|
localStorage.setItem(`${locationStorageKeyId}_${location.path[1]}`, JSON.stringify(location))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
locationWritable.set(location)
|
locationWritable.set(location)
|
||||||
|
@ -29,7 +29,8 @@ import {
|
|||||||
fetchMetadataLocalStorage,
|
fetchMetadataLocalStorage,
|
||||||
getCurrentLocation,
|
getCurrentLocation,
|
||||||
navigate,
|
navigate,
|
||||||
setMetadataLocalStorage
|
setMetadataLocalStorage,
|
||||||
|
locationStorageKeyId
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import { workbenchId } from '@hcengineering/workbench'
|
import { workbenchId } from '@hcengineering/workbench'
|
||||||
|
|
||||||
@ -333,7 +334,7 @@ export function navigateToWorkspace (workspace: string, loginInfo?: WorkspaceLog
|
|||||||
// Json parse error could be ignored
|
// Json parse error could be ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const last = localStorage.getItem(`platform_last_loc_${workspace}`)
|
const last = localStorage.getItem(`${locationStorageKeyId}_${workspace}`)
|
||||||
if (last !== null) {
|
if (last !== null) {
|
||||||
navigate(JSON.parse(last))
|
navigate(JSON.parse(last))
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
navigate,
|
navigate,
|
||||||
resolvedLocationStore,
|
resolvedLocationStore,
|
||||||
setMetadataLocalStorage,
|
setMetadataLocalStorage,
|
||||||
IconCheck
|
IconCheck,
|
||||||
|
locationStorageKeyId
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import { workbenchId } from '@hcengineering/workbench'
|
import { workbenchId } from '@hcengineering/workbench'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
@ -72,7 +73,7 @@
|
|||||||
closePopup()
|
closePopup()
|
||||||
closePopup()
|
closePopup()
|
||||||
if (ws !== getCurrentLocation().path[1]) {
|
if (ws !== getCurrentLocation().path[1]) {
|
||||||
const last = localStorage.getItem(`platform_last_loc_${ws}`)
|
const last = localStorage.getItem(`${locationStorageKeyId}_${ws}`)
|
||||||
if (last !== null) {
|
if (last !== null) {
|
||||||
navigate(JSON.parse(last))
|
navigate(JSON.parse(last))
|
||||||
} else navigate({ path: [workbenchId, ws] })
|
} else navigate({ path: [workbenchId, ws] })
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import { IntlString, broadcastEvent, getMetadata, getResource } from '@hcengineering/platform'
|
import { IntlString, broadcastEvent, getMetadata, getResource } from '@hcengineering/platform'
|
||||||
import { ActionContext, createQuery, getClient } from '@hcengineering/presentation'
|
import { ActionContext, createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import setting from '@hcengineering/setting'
|
import setting from '@hcengineering/setting'
|
||||||
|
import { locationStorageKeyId } from '@hcengineering/ui'
|
||||||
import {
|
import {
|
||||||
AnyComponent,
|
AnyComponent,
|
||||||
CompAndProps,
|
CompAndProps,
|
||||||
@ -107,7 +108,7 @@
|
|||||||
let panelInstance: PanelInstance
|
let panelInstance: PanelInstance
|
||||||
let popupInstance: Popup
|
let popupInstance: Popup
|
||||||
|
|
||||||
let visibileNav: boolean = true
|
let visibileNav: boolean = getMetadata(workbench.metadata.NavigationExpandedDefault) ?? true
|
||||||
async function toggleNav (): Promise<void> {
|
async function toggleNav (): Promise<void> {
|
||||||
visibileNav = !visibileNav
|
visibileNav = !visibileNav
|
||||||
closeTooltip()
|
closeTooltip()
|
||||||
@ -288,7 +289,7 @@
|
|||||||
const fragment = loc.fragment
|
const fragment = loc.fragment
|
||||||
let navigateDone = false
|
let navigateDone = false
|
||||||
if (app === undefined) {
|
if (app === undefined) {
|
||||||
const last = localStorage.getItem(`platform_last_loc_${loc.path[1]}`)
|
const last = localStorage.getItem(`${locationStorageKeyId}_${loc.path[1]}`)
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
const lastValue = JSON.parse(last)
|
const lastValue = JSON.parse(last)
|
||||||
navigateDone = navigate(lastValue)
|
navigateDone = navigate(lastValue)
|
||||||
@ -332,7 +333,7 @@
|
|||||||
space === undefined &&
|
space === undefined &&
|
||||||
((navigatorModel?.spaces?.length ?? 0) > 0 || (navigatorModel?.specials?.length ?? 0) > 0)
|
((navigatorModel?.spaces?.length ?? 0) > 0 || (navigatorModel?.specials?.length ?? 0) > 0)
|
||||||
) {
|
) {
|
||||||
const last = localStorage.getItem(`platform_last_loc_${app}`)
|
const last = localStorage.getItem(`${locationStorageKeyId}_${app}`)
|
||||||
if (last !== null) {
|
if (last !== null) {
|
||||||
const newLocation: Location = JSON.parse(last)
|
const newLocation: Location = JSON.parse(last)
|
||||||
if (newLocation.path[3] != null) {
|
if (newLocation.path[3] != null) {
|
||||||
@ -363,7 +364,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (app !== undefined) {
|
if (app !== undefined) {
|
||||||
localStorage.setItem(`platform_last_loc_${app}`, originalLoc)
|
localStorage.setItem(`${locationStorageKeyId}_${app}`, originalLoc)
|
||||||
}
|
}
|
||||||
currentQuery = loc.query
|
currentQuery = loc.query
|
||||||
if (fragment !== currentFragment) {
|
if (fragment !== currentFragment) {
|
||||||
@ -514,8 +515,10 @@
|
|||||||
visibileNav = false
|
visibileNav = false
|
||||||
navFloat = true
|
navFloat = true
|
||||||
} else if ($deviceInfo.docWidth > 1024 && navFloat) {
|
} else if ($deviceInfo.docWidth > 1024 && navFloat) {
|
||||||
navFloat = false
|
if (getMetadata(workbench.metadata.NavigationExpandedDefault) === undefined) {
|
||||||
visibileNav = true
|
navFloat = false
|
||||||
|
visibileNav = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const checkOnHide = (): void => {
|
const checkOnHide = (): void => {
|
||||||
if (visibileNav && $deviceInfo.docWidth <= 1024) visibileNav = false
|
if (visibileNav && $deviceInfo.docWidth <= 1024) visibileNav = false
|
||||||
|
@ -139,7 +139,9 @@ export default plugin(workbenchId, {
|
|||||||
ExcludedApplications: '' as Metadata<Ref<Application>[]>,
|
ExcludedApplications: '' as Metadata<Ref<Application>[]>,
|
||||||
DefaultApplication: '' as Metadata<string>,
|
DefaultApplication: '' as Metadata<string>,
|
||||||
DefaultSpace: '' as Metadata<Ref<Space>>,
|
DefaultSpace: '' as Metadata<Ref<Space>>,
|
||||||
DefaultSpecial: '' as Metadata<string>
|
DefaultSpecial: '' as Metadata<string>,
|
||||||
|
// Default for navigation expanded state
|
||||||
|
NavigationExpandedDefault: '' as Metadata<boolean>
|
||||||
},
|
},
|
||||||
actionImpl: {
|
actionImpl: {
|
||||||
Navigate: '' as ViewAction<{
|
Navigate: '' as ViewAction<{
|
||||||
|
@ -625,9 +625,8 @@ export async function restore (
|
|||||||
model: 'upgrade'
|
model: 'upgrade'
|
||||||
})) as unknown as CoreClient & BackupClient
|
})) as unknown as CoreClient & BackupClient
|
||||||
|
|
||||||
try {
|
async function processDomain (c: Domain): Promise<boolean> {
|
||||||
for (const c of domains) {
|
try {
|
||||||
console.log('loading server changeset for', c)
|
|
||||||
const changeset = await loadDigest(storage, snapshots, c, date)
|
const changeset = await loadDigest(storage, snapshots, c, date)
|
||||||
// We need to load full changeset from server
|
// We need to load full changeset from server
|
||||||
const serverChangeset = new Map<Ref<Doc>, string>()
|
const serverChangeset = new Map<Ref<Doc>, string>()
|
||||||
@ -798,6 +797,23 @@ export async function restore (
|
|||||||
await connection.clean(c, part)
|
await connection.clean(c, part)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
|
} catch (err: any) {
|
||||||
|
console.log('error', err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const c of domains) {
|
||||||
|
console.log('loading server changeset for', c)
|
||||||
|
let retry = 3
|
||||||
|
while (retry > 0) {
|
||||||
|
retry--
|
||||||
|
if (await processDomain(c)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await connection.close()
|
await connection.close()
|
||||||
|
@ -130,7 +130,7 @@ class ElasticDataAdapter implements DbAdapter {
|
|||||||
if (e?.meta?.body?.error?.type === 'index_not_found_exception') {
|
if (e?.meta?.body?.error?.type === 'index_not_found_exception') {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
console.error(e)
|
console.error('elastic error:', e)
|
||||||
throw new PlatformError(e)
|
throw new PlatformError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user