diff --git a/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte b/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte index a5f01f8785..951047b717 100644 --- a/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte +++ b/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte @@ -56,14 +56,22 @@ let _id = currentMessage._id let inputContent = currentMessage.message - $: createdMessageQuery.query(_class, { _id }, (result: ChatMessage[]) => { - if (result.length > 0 && _id !== chatMessage?._id) { - // Ouch we have got comment with same id created already. - currentMessage = getDefault() - _id = currentMessage._id - inputRef.removeDraft(false) - } - }) + $: if (currentDraft != null) { + createdMessageQuery.query(_class, { _id }, (result: ChatMessage[]) => { + if (result.length > 0 && _id !== chatMessage?._id) { + // Ouch we have got comment with same id created already. + clear() + } + }) + } else { + createdMessageQuery.unsubscribe() + } + + function clear (): void { + currentMessage = getDefault() + _id = currentMessage._id + inputRef.removeDraft(false) + } function objectChange (draft: MessageDraft, empty: Partial) { if (shouldSaveDraft) { @@ -131,11 +139,11 @@ objectClass: parentMessage.attachedToClass, objectId: parentMessage.attachedTo }, - _id as Ref, - Date.now(), - account._id + _id as Ref ) + clear() + await client.update(parentMessage, { lastReply: Date.now() }) const hasPerson = !!parentMessage.repliedPersons?.includes(account.person) @@ -151,10 +159,9 @@ object._class, collection, { message, attachments }, - _id, - Date.now(), - account._id + _id ) + clear() } } diff --git a/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte b/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte index 685b90ee10..9e91866efd 100644 --- a/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte @@ -66,7 +66,6 @@ const hierarchy = client.getHierarchy() let issue: WithLookup | undefined - let currentProject: Project | undefined let title = '' let innerWidth: number let descriptionBox: AttachmentStyleBoxCollabEditor @@ -99,14 +98,15 @@ ;[issue] = result if (issue !== undefined) { title = issue.title - currentProject = issue.$lookup?.space } }, - { lookup: { attachedTo: tracker.class.Issue, space: tracker.class.Project } } + { + limit: 1 + } ) $: canSave = title.trim().length > 0 - $: parentIssue = issue?.$lookup?.attachedTo + $: hasParentIssue = issue?.attachedTo !== tracker.ids.NoParent let saved = false async function save (): Promise { @@ -191,7 +191,7 @@ on:select > - {#if !embedded} + {#if !embedded && issue.attachedTo !== tracker.ids.NoParent} {/if} {#if embedded} @@ -205,10 +205,7 @@ {#if (projectType?.tasks.length ?? 0) > 1 && taskType !== undefined} ({taskType.name}) {/if} - + - {#if parentIssue} + {#if hasParentIssue}
- {#if currentProject} - - {:else} - - {/if} +
{/if}
- {#key issue._id !== undefined && currentProject !== undefined} - {#if currentProject !== undefined} - - {/if} + {#key issue._id} + {/key}
@@ -303,7 +294,7 @@ - {#if issue !== undefined && currentProject} + {#if issue !== undefined}
{/if} diff --git a/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte b/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte index d86d6923f3..d8710c3167 100644 --- a/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte @@ -36,8 +36,11 @@ import IssueStatusIcon from '../IssueStatusIcon.svelte' export let issue: WithLookup + $: parentIssueId = issue.attachedTo !== tracker.ids.NoParent ? issue.attachedTo : undefined + let parentIssue: Issue | undefined = undefined + const parentQuery = createQuery() - const subIssuesQeury = createQuery() + const subIssuesQuery = createQuery() let subIssues: WithLookup[] | undefined let subIssuesElement: Element @@ -64,11 +67,10 @@ } $: areSubIssuesLoading = !subIssues - $: parentIssue = issue.$lookup?.attachedTo ? issue.$lookup?.attachedTo : null - $: if (parentIssue && parentIssue.subIssues > 0) { - subIssuesQeury.query( + $: if (parentIssueId) { + subIssuesQuery.query( tracker.class.Issue, - { space: issue.space, attachedTo: parentIssue._id }, + { attachedTo: parentIssueId }, (res) => { subIssues = res }, @@ -79,8 +81,21 @@ } } ) + parentQuery.query( + tracker.class.Issue, + { _id: parentIssueId }, + (res) => { + parentIssue = res[0] + }, + { + limit: 1 + } + ) } else { - subIssuesQeury.unsubscribe() + subIssuesQuery.unsubscribe() + parentQuery.unsubscribe() + parentIssue = undefined + subIssues = [] } $: parentStatus = parentIssue ? $statusStore.byId.get(parentIssue.status) : undefined diff --git a/plugins/tracker-resources/src/issues.ts b/plugins/tracker-resources/src/issues.ts index 965d299eb4..fff79e0f2d 100644 --- a/plugins/tracker-resources/src/issues.ts +++ b/plugins/tracker-resources/src/issues.ts @@ -25,11 +25,7 @@ export async function issueIdentifierProvider (client: TxOperations, ref: Ref): Promise { - const object = await client.findOne( - tracker.class.Issue, - { _id: ref as Ref }, - { lookup: { space: tracker.class.Project } } - ) + const object = await client.findOne(tracker.class.Issue, { _id: ref as Ref }) if (object === undefined) { return ''