TSK-850 issue link presenter send extra requests (#2750)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-16 15:52:19 +06:00 committed by GitHub
parent d3af23bbd1
commit 0972048655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 7 deletions

View File

@ -33,7 +33,8 @@ import core, {
RefTo,
Tx,
TxOperations,
TxResult
TxResult,
WithLookup
} from '@hcengineering/core'
import login from '@hcengineering/login'
import { getMetadata, getResource, IntlString } from '@hcengineering/platform'
@ -72,6 +73,22 @@ class UIClient extends TxOperations implements Client {
super(client, getCurrentAccount()._id)
}
override async findAll<T extends Doc>(
_class: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
): Promise<FindResult<T>> {
return await this.liveQuery.findAll(_class, query, options)
}
override async findOne<T extends Doc>(
_class: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
): Promise<WithLookup<T> | undefined> {
return await this.liveQuery.findOne(_class, query, options)
}
override async tx (tx: Tx): Promise<TxResult> {
return await super.tx(tx)
}

View File

@ -27,18 +27,24 @@ export async function getIssueTitle (client: TxOperations, ref: Ref<Doc>): Promi
return getIssueId(object.$lookup.space, object)
}
async function getTitle (doc: Doc): Promise<string> {
const client = getClient()
const issue = doc as Issue
const object = await client.findOne(tracker.class.Team, { _id: issue.space })
if (object === undefined) return `?-${issue.number}`
return getIssueId(object, issue)
}
export function generateIssuePanelUri (issue: Issue): string {
return getPanelURI(tracker.component.EditIssue, issue._id, issue._class, 'content')
}
export async function issueIdProvider (doc: Doc): Promise<string> {
const client = getClient()
return await getIssueTitle(client, doc._id)
return await getTitle(doc)
}
export async function issueLinkFragmentProvider (doc: Doc): Promise<string> {
const client = getClient()
return await getIssueTitle(client, doc._id).then((p) => `${trackerId}|${p}`)
return await getTitle(doc).then((p) => `${trackerId}|${p}`)
}
export async function issueTitleProvider (doc: Issue): Promise<string> {
@ -46,8 +52,7 @@ export async function issueTitleProvider (doc: Issue): Promise<string> {
}
export async function issueLinkProvider (doc: Doc): Promise<string> {
const client = getClient()
return await getIssueTitle(client, doc._id).then(generateIssueShortLink)
return await getTitle(doc).then(generateIssueShortLink)
}
export function generateIssueShortLink (issueId: string): string {