diff --git a/packages/presentation/src/connect.ts b/packages/presentation/src/connect.ts index 7cd9d96b2c..529f6de038 100644 --- a/packages/presentation/src/connect.ts +++ b/packages/presentation/src/connect.ts @@ -1,7 +1,7 @@ import client from '@hcengineering/client' import contact from '@hcengineering/contact' import core, { Client, setCurrentAccount, Version } from '@hcengineering/core' -import login from '@hcengineering/login' +import login, { loginId } from '@hcengineering/login' import { getMetadata, getResource, setMetadata } from '@hcengineering/platform' import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLocalStorage } from '@hcengineering/ui' import presentation from './plugin' @@ -11,6 +11,7 @@ export let versionError: string | undefined = '' export async function connect (title: string): Promise { const loc = getCurrentLocation() const ws = loc.path[1] + if (ws === undefined) return const tokens: Record = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {} const token = tokens[ws] setMetadata(login.metadata.LoginToken, token) @@ -19,7 +20,7 @@ export async function connect (title: string): Promise { if (token === undefined || endpoint === null || email === null) { navigate({ - path: [login.component.LoginApp], + path: [loginId], query: { navigateUrl: encodeURIComponent(JSON.stringify(loc)) } }) return @@ -35,7 +36,7 @@ export async function connect (title: string): Promise { () => { clearMetadata(ws) navigate({ - path: [login.component.LoginApp], + path: [loginId], query: {} }) } @@ -50,7 +51,7 @@ export async function connect (title: string): Promise { console.error('WARNING: no employee account found.') clearMetadata(ws) navigate({ - path: [login.component.LoginApp], + path: [loginId], query: { navigateUrl: encodeURIComponent(JSON.stringify(getCurrentLocation())) } }) return diff --git a/plugins/client-resources/src/index.ts b/plugins/client-resources/src/index.ts index 3723df5148..204540deef 100644 --- a/plugins/client-resources/src/index.ts +++ b/plugins/client-resources/src/index.ts @@ -41,9 +41,9 @@ export default async () => { ): Promise => { if (client instanceof Promise) { client = await client - await client.close() } if (token !== _token && client !== undefined) { + await client.close() client = undefined } if (client === undefined) { diff --git a/plugins/login-resources/src/components/InviteLink.svelte b/plugins/login-resources/src/components/InviteLink.svelte index a4ca31cce5..f4fc4070b4 100644 --- a/plugins/login-resources/src/components/InviteLink.svelte +++ b/plugins/login-resources/src/components/InviteLink.svelte @@ -20,13 +20,14 @@ import { createEventDispatcher } from 'svelte' import login from '../plugin' import InviteWorkspace from './icons/InviteWorkspace.svelte' + import { loginId } from '@hcengineering/login' const dispatch = createEventDispatcher() async function getLink (): Promise { const inviteId = await getInviteLink() const loc = getCurrentLocation() - loc.path[0] = login.component.LoginApp + loc.path[0] = loginId loc.path[1] = 'join' loc.path.length = 2 loc.query = { diff --git a/plugins/setting-resources/src/components/Settings.svelte b/plugins/setting-resources/src/components/Settings.svelte index 2b5ccc84ec..87e7984370 100644 --- a/plugins/setting-resources/src/components/Settings.svelte +++ b/plugins/setting-resources/src/components/Settings.svelte @@ -27,7 +27,7 @@ } from '@hcengineering/ui' import { onDestroy } from 'svelte' import CategoryElement from './CategoryElement.svelte' - import login from '@hcengineering/login' + import login, { loginId } from '@hcengineering/login' import { AccountRole, getCurrentAccount } from '@hcengineering/core' import { EmployeeAccount } from '@hcengineering/contact' import { setMetadata } from '@hcengineering/platform' @@ -76,10 +76,10 @@ setMetadata(login.metadata.LoginToken, null) setMetadataLocalStorage(login.metadata.LoginEndpoint, null) setMetadataLocalStorage(login.metadata.LoginEmail, null) - navigate({ path: [login.component.LoginApp] }) + navigate({ path: [loginId] }) } function selectWorkspace (): void { - navigate({ path: [login.component.LoginApp, 'selectWorkspace'] }) + navigate({ path: [loginId, 'selectWorkspace'] }) } function inviteWorkspace (): void { showPopup(login.component.InviteLink, {}) diff --git a/plugins/tracker-resources/src/components/AccountPopup.svelte b/plugins/tracker-resources/src/components/AccountPopup.svelte index e6fe808fa1..ae8cffa496 100644 --- a/plugins/tracker-resources/src/components/AccountPopup.svelte +++ b/plugins/tracker-resources/src/components/AccountPopup.svelte @@ -15,7 +15,7 @@ -{#key $location.path[1]} - {#await connect(getMetadata(workbench.metadata.PlatformTitle) ?? 'Platform')} - - {:then client} - {#if !client && versionError} -
-

Server is under maintenance.

- {versionError} -
- {:else if client} - - - - {/if} - {:catch error} -
{error} -- {error.stack}
- {/await} -{/key} +{#if $location.path[0] === workbenchId || $location.path[0] === workbench.component.WorkbenchApp} + {#key $location.path[1]} + {#await connect(getMetadata(workbench.metadata.PlatformTitle) ?? 'Platform')} + + {:then client} + {#if !client && versionError} +
+

Server is under maintenance.

+ {versionError} +
+ {:else if client} + + + + {/if} + {:catch error} +
{error} -- {error.stack}
+ {/await} + {/key} +{/if}