mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-23 12:05:36 +00:00
UBER-528: Fix desktop navigation (#3450)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
54b74caf63
commit
7d5a257f1c
@ -114,7 +114,7 @@ declare global {
|
||||
}
|
||||
}
|
||||
const embeddedPlatform = window.embeddedPlatform ?? false
|
||||
const locationWritable = writable(embeddedPlatform ? { path: [] } : getRawCurrentLocation())
|
||||
const locationWritable = writable(getRawCurrentLocation())
|
||||
|
||||
console.log('embeddedPlatform', window.embeddedPlatform)
|
||||
|
||||
@ -124,7 +124,15 @@ if (!embeddedPlatform) {
|
||||
})
|
||||
}
|
||||
|
||||
export const location = embeddedPlatform ? locationWritable : derived(locationWritable, (loc) => loc)
|
||||
export const location = derived(locationWritable, (loc) => justClone(loc))
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function getLocation (): PlatformLocation {
|
||||
return justClone(get(location))
|
||||
}
|
||||
|
||||
export const resolvedLocationStore = writable(getRawCurrentLocation())
|
||||
let resolvedLocation = getRawCurrentLocation()
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { get, writable } from 'svelte/store'
|
||||
import { location, navigate } from './location'
|
||||
import { writable } from 'svelte/store'
|
||||
import { getLocation, navigate } from './location'
|
||||
import { AnyComponent, PopupAlignment } from './types'
|
||||
|
||||
export interface PanelProps {
|
||||
@ -29,7 +29,7 @@ export function showPanel (
|
||||
rightSection?: AnyComponent
|
||||
): void {
|
||||
openPanel(component, _id, _class, element, rightSection)
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
if (loc.fragment !== currentLocation) {
|
||||
loc.fragment = currentLocation
|
||||
navigate(loc)
|
||||
@ -58,7 +58,7 @@ export function closePanel (shoulRedirect: boolean = true): void {
|
||||
return { panel: undefined }
|
||||
})
|
||||
if (shoulRedirect) {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
loc.fragment = undefined
|
||||
currentLocation = undefined
|
||||
navigate(loc)
|
||||
|
@ -17,9 +17,8 @@
|
||||
import contact, { Employee, EmployeeAccount } from '@hcengineering/contact'
|
||||
import core, { Class, getCurrentAccount, Ref, Space } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { Label, Loading, location, navigate, TabList, SearchEdit } from '@hcengineering/ui'
|
||||
import { Label, Loading, navigate, TabList, SearchEdit, getLocation } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
import { get } from 'svelte/store'
|
||||
import { dateFileBrowserFilters, FileBrowserSortMode, fileTypeFileBrowserFilters, sortModeToOptionObject } from '..'
|
||||
import attachment from '../plugin'
|
||||
import AttachmentsGalleryView from './AttachmentsGalleryView.svelte'
|
||||
@ -30,11 +29,11 @@
|
||||
export let withHeader: boolean = true
|
||||
|
||||
const client = getClient()
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
const spaceId: Ref<Space> | undefined = loc.query?.spaceId as Ref<Space> | undefined
|
||||
|
||||
$: if (spaceId !== undefined) {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
loc.query = undefined
|
||||
navigate(loc)
|
||||
}
|
||||
|
@ -18,8 +18,7 @@
|
||||
import { ChunterMessage, ChunterSpace, Message } from '@hcengineering/chunter'
|
||||
import { Ref, Space, generateId, getCurrentAccount } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { location, navigate } from '@hcengineering/ui'
|
||||
import { get } from 'svelte/store'
|
||||
import { getLocation, navigate } from '@hcengineering/ui'
|
||||
import { createBacklinks } from '../backlinks'
|
||||
import chunter from '../plugin'
|
||||
import Channel from './Channel.svelte'
|
||||
@ -59,7 +58,7 @@
|
||||
}
|
||||
|
||||
function openThread (_id: Ref<Message>) {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
loc.path[4] = _id
|
||||
navigate(loc)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||
import { IntlString, Resources, translate } from '@hcengineering/platform'
|
||||
import preference from '@hcengineering/preference'
|
||||
import { MessageBox, getClient } from '@hcengineering/presentation'
|
||||
import { location, navigate, showPopup } from '@hcengineering/ui'
|
||||
import { getLocation, navigate, showPopup } from '@hcengineering/ui'
|
||||
import ChannelHeader from './components/ChannelHeader.svelte'
|
||||
import ChannelPresenter from './components/ChannelPresenter.svelte'
|
||||
import ChannelView from './components/ChannelView.svelte'
|
||||
@ -57,7 +57,7 @@ import TxCommentCreate from './components/activity/TxCommentCreate.svelte'
|
||||
import TxMessageCreate from './components/activity/TxMessageCreate.svelte'
|
||||
|
||||
import notification from '@hcengineering/notification'
|
||||
import { get, writable } from 'svelte/store'
|
||||
import { writable } from 'svelte/store'
|
||||
import { updateBacklinksList } from './backlinks'
|
||||
import { getDmName, getLink, getTitle, resolveLocation } from './utils'
|
||||
|
||||
@ -179,7 +179,7 @@ export async function ArchiveChannel (channel: Channel, evt: any, afterArchive?:
|
||||
client.update(channel, { archived: true })
|
||||
if (afterArchive != null) afterArchive()
|
||||
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
if (loc.path[3] === channel._id) {
|
||||
loc.path.length = 3
|
||||
navigate(loc)
|
||||
|
@ -6,7 +6,7 @@ import { Asset } from '@hcengineering/platform'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
getPanelURI,
|
||||
location,
|
||||
getLocation,
|
||||
Location,
|
||||
navigate,
|
||||
ResolvedLocation,
|
||||
@ -89,7 +89,7 @@ export function getDay (time: Timestamp): Timestamp {
|
||||
}
|
||||
|
||||
export function openMessageFromSpecial (message: ChunterMessage): void {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
|
||||
if (message.attachedToClass === chunter.class.ChunterSpace) {
|
||||
loc.path.length = 4
|
||||
@ -103,7 +103,7 @@ export function openMessageFromSpecial (message: ChunterMessage): void {
|
||||
}
|
||||
|
||||
export function navigateToSpecial (specialId: string): void {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
loc.path[2] = chunterId
|
||||
loc.path[3] = specialId
|
||||
navigate(loc)
|
||||
|
@ -16,8 +16,7 @@
|
||||
import core, { Class, Doc, Obj, Ref } from '@hcengineering/core'
|
||||
import { IntlString } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { AnySvelteComponent, location, Icon, Label, navigate } from '@hcengineering/ui'
|
||||
import { get } from 'svelte/store'
|
||||
import { AnySvelteComponent, getLocation, Icon, Label, navigate } from '@hcengineering/ui'
|
||||
import setting from '../plugin'
|
||||
import { filterDescendants } from '../utils'
|
||||
import ClassAttributes from './ClassAttributes.svelte'
|
||||
@ -33,14 +32,14 @@
|
||||
| undefined
|
||||
export let withoutHeader = false
|
||||
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
let _class: Ref<Class<Doc>> | undefined = ofClass ?? (loc.query?._class as Ref<Class<Doc>> | undefined)
|
||||
|
||||
$: if (_class !== undefined && ofClass === undefined) {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
loc.query = undefined
|
||||
navigate(loc)
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
deviceOptionsStore as deviceInfo,
|
||||
getCurrentLocation,
|
||||
location,
|
||||
getLocation,
|
||||
navigate,
|
||||
openPanel,
|
||||
popupstore,
|
||||
@ -59,7 +60,6 @@
|
||||
} from '@hcengineering/view-resources'
|
||||
import type { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@hcengineering/workbench'
|
||||
import { getContext, onDestroy, onMount, tick } from 'svelte'
|
||||
import { get } from 'svelte/store'
|
||||
import { subscribeMobile } from '../mobile'
|
||||
import workbench from '../plugin'
|
||||
import { workspacesStore } from '../utils'
|
||||
@ -423,7 +423,7 @@
|
||||
}
|
||||
|
||||
function closeAside (): void {
|
||||
const loc = get(location)
|
||||
const loc = getLocation()
|
||||
loc.path.length = 4
|
||||
checkOnHide()
|
||||
navigate(loc)
|
||||
|
Loading…
Reference in New Issue
Block a user