mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-08 02:37:44 +02:00
UBERF-6267: Fix few platform troubles (#5142)
This commit is contained in:
@@ -420,7 +420,8 @@ async function restoreTaskTypes (client: MigrationClient): Promise<void> {
|
||||
)[0] as TxMixin<any, any>
|
||||
|
||||
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
|
||||
|
||||
@@ -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' }
|
||||
|
||||
@@ -179,16 +179,16 @@ export async function setClient (_client: MeasureClient): Promise<void> {
|
||||
void uiClient.doNotify(...tx)
|
||||
}
|
||||
if (needRefresh || globalQueries.length > 0) {
|
||||
await refreshClient()
|
||||
await refreshClient(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function refreshClient (): Promise<void> {
|
||||
export async function refreshClient (clean: boolean): Promise<void> {
|
||||
if (!(liveQuery?.isClosed() ?? true)) {
|
||||
await liveQuery?.refreshConnect()
|
||||
await liveQuery?.refreshConnect(clean)
|
||||
for (const q of globalQueries) {
|
||||
q.refreshClient()
|
||||
}
|
||||
|
||||
+16
-13
@@ -87,7 +87,7 @@ interface DocumentRef {
|
||||
* @public
|
||||
*/
|
||||
export class LiveQuery implements WithTx, Client {
|
||||
private client: Client
|
||||
private readonly client: Client
|
||||
private readonly queries: Map<Ref<Class<Doc>>, Query[]> = new Map<Ref<Class<Doc>>, 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<void> {
|
||||
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<void> {
|
||||
async refreshConnect (clean: boolean): Promise<void> {
|
||||
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
|
||||
|
||||
@@ -75,7 +75,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
console.log('WorkbenchClient: onConnect', event)
|
||||
try {
|
||||
if ((_clientSet && event === ClientConnectEvent.Connected) || event === ClientConnectEvent.Refresh) {
|
||||
void refreshClient()
|
||||
void refreshClient(true)
|
||||
}
|
||||
|
||||
if (event === ClientConnectEvent.Upgraded) {
|
||||
|
||||
@@ -13,23 +13,24 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import { Employee } from '@hcengineering/contact'
|
||||
import { AccountArrayEditor, AssigneeBox } from '@hcengineering/contact-resources'
|
||||
import core, {
|
||||
Account,
|
||||
Data,
|
||||
DocumentUpdate,
|
||||
RolesAssignment,
|
||||
Ref,
|
||||
Role,
|
||||
RolesAssignment,
|
||||
SortingOrder,
|
||||
SpaceType,
|
||||
generateId,
|
||||
getCurrentAccount
|
||||
} from '@hcengineering/core'
|
||||
import { Asset } from '@hcengineering/platform'
|
||||
import presentation, { Card, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import task, { ProjectType } from '@hcengineering/task'
|
||||
import task, { ProjectType, TaskType } from '@hcengineering/task'
|
||||
import { taskTypeStore, typeStore } from '@hcengineering/task-resources'
|
||||
import { StyledTextBox } from '@hcengineering/text-editor'
|
||||
import { IssueStatus, Project, TimeReportDayType } from '@hcengineering/tracker'
|
||||
import {
|
||||
@@ -47,7 +48,7 @@
|
||||
} from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
import { IconPicker } from '@hcengineering/view-resources'
|
||||
import { typeStore, taskTypeStore } from '@hcengineering/task-resources'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import tracker from '../../plugin'
|
||||
import StatusSelector from '../issues/StatusSelector.svelte'
|
||||
@@ -185,8 +186,15 @@
|
||||
let typeId: Ref<ProjectType> | undefined = project?.type
|
||||
$: typeType = typeId !== undefined ? $typeStore.get(typeId) : undefined
|
||||
|
||||
$: if (defaultStatus === undefined && typeType !== undefined) {
|
||||
defaultStatus = typeType.statuses[0]?._id
|
||||
function findTaskTypes (typeId: Ref<SpaceType>): TaskType[] {
|
||||
return Array.from($taskTypeStore.values()).filter(
|
||||
(it) => it.parent === typeId && it.ofClass === tracker.class.Issue
|
||||
)
|
||||
}
|
||||
|
||||
$: if (defaultStatus === undefined && typeId !== undefined) {
|
||||
const sts = findTaskTypes(typeId)?.[0]?.statuses
|
||||
defaultStatus = sts?.[0]
|
||||
}
|
||||
|
||||
async function createProject (): Promise<void> {
|
||||
@@ -429,15 +437,15 @@
|
||||
<div class="antiGrid-row__header">
|
||||
<Label label={tracker.string.DefaultIssueStatus} />
|
||||
</div>
|
||||
<StatusSelector
|
||||
taskType={Array.from($taskTypeStore.values()).filter(
|
||||
(it) => it.parent === typeId && it.ofClass === tracker.class.Issue
|
||||
)[0]?._id}
|
||||
bind:value={defaultStatus}
|
||||
type={typeId}
|
||||
kind={'regular'}
|
||||
size={'large'}
|
||||
/>
|
||||
{#if typeId !== undefined}
|
||||
<StatusSelector
|
||||
taskType={findTaskTypes(typeId)[0]?._id}
|
||||
bind:value={defaultStatus}
|
||||
type={typeId}
|
||||
kind={'regular'}
|
||||
size={'large'}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="antiGrid-row">
|
||||
|
||||
@@ -84,11 +84,14 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
return
|
||||
}
|
||||
|
||||
let tokenChanged = false
|
||||
|
||||
if (_token !== token && _client !== undefined) {
|
||||
// We need to flush all data from memory
|
||||
await purgeClient()
|
||||
await _client.close()
|
||||
_client = undefined
|
||||
tokenChanged = true
|
||||
}
|
||||
if (_client !== undefined) {
|
||||
return _client
|
||||
@@ -119,7 +122,8 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
console.log('WorkbenchClient: onConnect', event)
|
||||
try {
|
||||
if ((_clientSet && event === ClientConnectEvent.Connected) || event === ClientConnectEvent.Refresh) {
|
||||
void refreshClient()
|
||||
void refreshClient(tokenChanged)
|
||||
tokenChanged = false
|
||||
}
|
||||
|
||||
if (event === ClientConnectEvent.Upgraded) {
|
||||
|
||||
Reference in New Issue
Block a user