From 7a7ea1e92bc2b4bad48152fc5c49c2b401f1d22d Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 2 Apr 2024 19:40:52 +0700 Subject: [PATCH] UBERF-6267: Fix few platform troubles (#5142) --- models/tracker/src/migration.ts | 3 +- models/tracker/src/viewlets.ts | 11 +++--- packages/presentation/src/utils.ts | 6 +-- packages/query/src/index.ts | 29 +++++++------- plugins/guest-resources/src/connect.ts | 2 +- .../components/projects/CreateProject.svelte | 38 +++++++++++-------- plugins/workbench-resources/src/connect.ts | 6 ++- 7 files changed, 56 insertions(+), 39 deletions(-) diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index ff0966f503..03533b5f3c 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -420,7 +420,8 @@ async function restoreTaskTypes (client: MigrationClient): Promise { )[0] as TxMixin if (typeMixin === undefined) { - throw new Error('No type mixin found for the task type being restored') + console.error(new Error('No type mixin found for the task type being restored')) + continue } // Get statuses and categories diff --git a/models/tracker/src/viewlets.ts b/models/tracker/src/viewlets.ts index ee2711ca1d..1065b2abf4 100644 --- a/models/tracker/src/viewlets.ts +++ b/models/tracker/src/viewlets.ts @@ -525,7 +525,7 @@ export function defineViewlets (builder: Builder): void { attachTo: tracker.class.Project, descriptor: view.viewlet.List, viewOptions: { - groupBy: ['type', 'createdBy'], + groupBy: ['createdBy'], orderBy: [ ['type', SortingOrder.Descending], ['modifiedOn', SortingOrder.Descending], @@ -549,10 +549,11 @@ export function defineViewlets (builder: Builder): void { sortingKey: 'members', props: { readonly: true, kind: 'list' } }, - { - key: 'type', - props: { kind: 'list' } - }, + // TODO: Need return type in future + // { + // key: 'type', + // props: { kind: 'list' } + // }, { key: 'defaultAssignee', props: { kind: 'list' } diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index a388480807..d5608b9688 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -179,16 +179,16 @@ export async function setClient (_client: MeasureClient): Promise { void uiClient.doNotify(...tx) } if (needRefresh || globalQueries.length > 0) { - await refreshClient() + await refreshClient(true) } } /** * @public */ -export async function refreshClient (): Promise { +export async function refreshClient (clean: boolean): Promise { if (!(liveQuery?.isClosed() ?? true)) { - await liveQuery?.refreshConnect() + await liveQuery?.refreshConnect(clean) for (const q of globalQueries) { q.refreshClient() } diff --git a/packages/query/src/index.ts b/packages/query/src/index.ts index f7395be3bd..f2d5d1f4b9 100644 --- a/packages/query/src/index.ts +++ b/packages/query/src/index.ts @@ -87,7 +87,7 @@ interface DocumentRef { * @public */ export class LiveQuery implements WithTx, Client { - private client: Client + private readonly client: Client private readonly queries: Map>, Query[]> = new Map>, Query[]>() private readonly queue: Query[] = [] private queryCounter: number = 0 @@ -100,11 +100,6 @@ export class LiveQuery implements WithTx, Client { this.client = client } - async updateClient (client: Client): Promise { - this.client = client - await this.refreshConnect() - } - public isClosed (): boolean { return this.closed } @@ -123,13 +118,13 @@ export class LiveQuery implements WithTx, Client { } // Perform refresh of content since connection established. - async refreshConnect (): Promise { + async refreshConnect (clean: boolean): Promise { for (const q of [...this.queue]) { if (!this.removeFromQueue(q)) { try { - q.callbacks.forEach((callback) => { - callback(toFindResult([], 0)) - }) + if (clean) { + this.cleanQuery(q) + } void this.refresh(q) } catch (err: any) { if (err instanceof PlatformError) { @@ -144,9 +139,9 @@ export class LiveQuery implements WithTx, Client { for (const v of this.queries.values()) { for (const q of v) { try { - q.callbacks.forEach((callback) => { - callback(toFindResult([], 0)) - }) + if (clean) { + this.cleanQuery(q) + } void this.refresh(q) } catch (err: any) { if (err instanceof PlatformError) { @@ -160,6 +155,14 @@ export class LiveQuery implements WithTx, Client { } } + private cleanQuery (q: Query): void { + q.callbacks.forEach((callback) => { + callback(toFindResult([], 0)) + }) + q.result = [] + q.total = -1 + } + private match (q: Query, doc: Doc, skipLookup = false): boolean { if (!this.getHierarchy().isDerived(doc._class, q._class)) { // Check if it is not a mixin and not match class diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index 19e20050d5..875a4ded19 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -75,7 +75,7 @@ export async function connect (title: string): Promise { console.log('WorkbenchClient: onConnect', event) try { if ((_clientSet && event === ClientConnectEvent.Connected) || event === ClientConnectEvent.Refresh) { - void refreshClient() + void refreshClient(true) } if (event === ClientConnectEvent.Upgraded) { diff --git a/plugins/tracker-resources/src/components/projects/CreateProject.svelte b/plugins/tracker-resources/src/components/projects/CreateProject.svelte index 0f1d273b93..8400733c84 100644 --- a/plugins/tracker-resources/src/components/projects/CreateProject.svelte +++ b/plugins/tracker-resources/src/components/projects/CreateProject.svelte @@ -13,23 +13,24 @@ // limitations under the License. -->