From ea44bc838981a70f976b11279a3028b0b1ca8235 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 16 Mar 2023 11:47:55 +0700 Subject: [PATCH] Fix short links quickfix (#2745) Signed-off-by: Andrey Sobolev --- plugins/chunter-resources/src/utils.ts | 29 +++---------------- plugins/contact-resources/src/utils.ts | 22 ++------------ .../src/components/DocNavLink.svelte | 2 +- server-plugins/contact-resources/src/index.ts | 13 +-------- 4 files changed, 9 insertions(+), 57 deletions(-) diff --git a/plugins/chunter-resources/src/utils.ts b/plugins/chunter-resources/src/utils.ts index b385d33c4d..b6d0f02f59 100644 --- a/plugins/chunter-resources/src/utils.ts +++ b/plugins/chunter-resources/src/utils.ts @@ -1,22 +1,11 @@ import { chunterId, ChunterMessage, Comment, ThreadMessage } from '@hcengineering/chunter' import contact, { EmployeeAccount, getName } from '@hcengineering/contact' -import { - Class, - Client, - Doc, - getCurrentAccount, - matchQuery, - Obj, - Ref, - SortingOrder, - Space, - Timestamp -} from '@hcengineering/core' +import { Class, Client, Doc, getCurrentAccount, Obj, Ref, SortingOrder, Space, Timestamp } from '@hcengineering/core' import { Asset } from '@hcengineering/platform' import { getClient } from '@hcengineering/presentation' -import { getCurrentLocation, navigate, Location, getPanelURI } from '@hcengineering/ui' -import { workbenchId } from '@hcengineering/workbench' +import { getCurrentLocation, getPanelURI, Location, navigate } from '@hcengineering/ui' import view from '@hcengineering/view' +import { workbenchId } from '@hcengineering/workbench' import { get, writable } from 'svelte/store' import chunter from './plugin' @@ -142,17 +131,7 @@ export async function getFragment (doc: Doc): Promise { label = clazz.shortLabel } label = label ?? doc._class - let length = 5 - let id = doc._id.slice(-length) - const contacts = await client.findAll(chunter.class.Comment, {}, { projection: { _id: 1 } }) - let res = matchQuery(contacts, { _id: { $like: `@${id}` } }, chunter.class.Comment, hierarchy) - while (res.length > 1) { - length++ - id = doc._id.slice(-length) - res = matchQuery(contacts, { _id: { $like: `@${id}` } }, chunter.class.Comment, hierarchy) - } - - return `${chunterId}|${label}-${id}` + return `${chunterId}|${label}-${doc._id}` } export async function resolveLocation (loc: Location): Promise { diff --git a/plugins/contact-resources/src/utils.ts b/plugins/contact-resources/src/utils.ts index 448c8d59d0..08b37c7973 100644 --- a/plugins/contact-resources/src/utils.ts +++ b/plugins/contact-resources/src/utils.ts @@ -23,16 +23,7 @@ import { formatName, getName } from '@hcengineering/contact' -import { - Doc, - getCurrentAccount, - matchQuery, - ObjQueryType, - Ref, - SortingOrder, - Timestamp, - toIdMap -} from '@hcengineering/core' +import { Doc, getCurrentAccount, ObjQueryType, Ref, SortingOrder, Timestamp, toIdMap } from '@hcengineering/core' import { createQuery, getClient } from '@hcengineering/presentation' import { TemplateDataProvider } from '@hcengineering/templates' import { getPanelURI, Location } from '@hcengineering/ui' @@ -162,15 +153,8 @@ export async function getContactLink (doc: Doc): Promise { label = clazz.shortLabel } label = label ?? 'CONT' - let length = 5 - let id = doc._id.slice(-length) - const contacts = await client.findAll(clazz._id, {}, { projection: { _id: 1 } }) - let res = matchQuery(contacts, { _id: { $like: `@${id}` } }, clazz._id, hierarchy) - while (res.length > 1) { - length++ - id = doc._id.slice(-length) - res = matchQuery(contacts, { _id: { $like: `@${id}` } }, clazz._id, hierarchy) - } + + const id = doc._id return `${contactId}|${label}-${id}` } diff --git a/plugins/view-resources/src/components/DocNavLink.svelte b/plugins/view-resources/src/components/DocNavLink.svelte index bc49d81945..a99391f9ab 100644 --- a/plugins/view-resources/src/components/DocNavLink.svelte +++ b/plugins/view-resources/src/components/DocNavLink.svelte @@ -30,7 +30,7 @@ const client = getClient() const hierarchy = client.getHierarchy() - let href: string | undefined = getPanelURI(component, object._id, Hierarchy.mixinOrClass(object), 'content') + let href: string | undefined = '#' + getPanelURI(component, object._id, Hierarchy.mixinOrClass(object), 'content') async function getHref (object: Doc): Promise { href = `#${await getObjectLinkFragment(hierarchy, object, props, component)}` diff --git a/server-plugins/contact-resources/src/index.ts b/server-plugins/contact-resources/src/index.ts index 43053a4e5e..2224df82b3 100644 --- a/server-plugins/contact-resources/src/index.ts +++ b/server-plugins/contact-resources/src/index.ts @@ -23,7 +23,6 @@ import core, { Collection, concatLink, Doc, - matchQuery, Obj, Ref, RefTo, @@ -280,17 +279,7 @@ async function getContactLink (doc: Doc, control: TriggerControl): Promise 1) { - length++ - id = doc._id.slice(-length) - res = matchQuery(contacts, { _id: { $like: `@${id}` } }, clazz._id, hierarchy) - } - - return `${contactId}|${label}-${id}` + return `${contactId}|${label}-${doc._id}` } /**