From c8357246b19f043b5804aaa138568b6d6d392238 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 27 Aug 2024 15:01:21 +0700 Subject: [PATCH] Fix a bulk of sentry errors (#6399) Signed-off-by: Andrey Sobolev --- packages/core/src/operator.ts | 4 +++- .../src/components/AttachmentStyledBox.svelte | 1 + .../src/components/AssigneePopup.svelte | 2 +- .../src/stores/editors/document/editor.ts | 8 +++++--- .../hr-resources/src/components/ScheduleView.svelte | 12 +++++++----- .../src/components/OptimizeSkills.svelte | 11 ++++++----- .../src/components/ClassAttributes.svelte | 6 ++++-- .../src/components/EditRelatedTargets.svelte | 3 ++- .../components/templates/EditIssueTemplate.svelte | 4 +++- 9 files changed, 32 insertions(+), 19 deletions(-) diff --git a/packages/core/src/operator.ts b/packages/core/src/operator.ts index e9151ffc7e..711aca85f8 100644 --- a/packages/core/src/operator.ts +++ b/packages/core/src/operator.ts @@ -33,7 +33,9 @@ function $push (document: Doc, keyval: Record): void { const arr = doc[key] as Array const desc = val as Position if ('$each' in desc) { - arr.splice(desc.$position ?? 0, 0, ...desc.$each) + if (arr != null) { + arr.splice(desc.$position ?? 0, 0, ...desc.$each) + } } else { arr.push(val) } diff --git a/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte b/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte index c87a8ad08e..c9455032df 100644 --- a/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte +++ b/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte @@ -367,6 +367,7 @@ name="file" id="file" style="display: none" + disabled={inputFile == null} on:change={fileSelected} /> diff --git a/plugins/contact-resources/src/components/AssigneePopup.svelte b/plugins/contact-resources/src/components/AssigneePopup.svelte index 1abab530d8..dc58b83a1d 100644 --- a/plugins/contact-resources/src/components/AssigneePopup.svelte +++ b/plugins/contact-resources/src/components/AssigneePopup.svelte @@ -135,7 +135,7 @@ async function handleSelection (evt: Event | undefined, selection: number): Promise { const person = contacts[selection] - selected = allowDeselect && person._id === selected ? undefined : person._id + selected = allowDeselect && person?._id === selected ? undefined : person?._id dispatch('close', selected !== undefined ? person : undefined) } diff --git a/plugins/controlled-documents-resources/src/stores/editors/document/editor.ts b/plugins/controlled-documents-resources/src/stores/editors/document/editor.ts index 7f6237ef11..4b1ea606f7 100644 --- a/plugins/controlled-documents-resources/src/stores/editors/document/editor.ts +++ b/plugins/controlled-documents-resources/src/stores/editors/document/editor.ts @@ -63,9 +63,11 @@ const $documentAllVersions = createStore([]) .on(documentAllVersionsUpdated, (_, payload) => payload) .reset(controlledDocumentClosed) -export const $documentAllVersionsDescSorted = $documentAllVersions.map((docs) => - docs.toSorted((a, b) => documentCompareFn(a, b) * -1) -) +export const $documentAllVersionsDescSorted = $documentAllVersions.map((docs) => { + const result = [...docs] + result.sort((a, b) => documentCompareFn(a, b) * -1) + return result +}) export const $documentSnapshots = createStore([]) .on(documentSnapshotsUpdated, (_, payload) => payload) diff --git a/plugins/hr-resources/src/components/ScheduleView.svelte b/plugins/hr-resources/src/components/ScheduleView.svelte index 22d6f057ef..a9720df095 100644 --- a/plugins/hr-resources/src/components/ScheduleView.svelte +++ b/plugins/hr-resources/src/components/ScheduleView.svelte @@ -216,11 +216,13 @@ tasks: new Map() } const tsk = r.$lookup?.attachedTo as Issue - newMap.set(r.employee, { - value: or.value + r.value, - reports: [...or.reports, r], - tasks: or.tasks.set(tsk._id, tsk) - }) + if (tsk !== undefined) { + newMap.set(r.employee, { + value: or.value + r.value, + reports: [...or.reports, r], + tasks: or.tasks.set(tsk._id, tsk) + }) + } } } timeReports = newMap diff --git a/plugins/recruit-resources/src/components/OptimizeSkills.svelte b/plugins/recruit-resources/src/components/OptimizeSkills.svelte index 5ce4905c69..b2a2290e10 100644 --- a/plugins/recruit-resources/src/components/OptimizeSkills.svelte +++ b/plugins/recruit-resources/src/components/OptimizeSkills.svelte @@ -42,7 +42,7 @@ let loading2: boolean = false $: { loading1 = true - getClient() + void getClient() .findAll(tags.class.TagCategory, { targetClass }) .then((result) => { categories = result @@ -52,14 +52,15 @@ $: { loading2 = true - getClient() + void getClient() .findAll( tags.class.TagElement, { category: { $in: Array.from(categories.map((it) => it._id)) } }, { sort: { title: 1 } } ) .then((res) => { - elements = res.toSorted((a, b) => prepareTitle(a.title).localeCompare(prepareTitle(b.title))) + res.sort((a, b) => prepareTitle(a.title).localeCompare(prepareTitle(b.title))) + elements = res loading2 = false }) } @@ -157,7 +158,7 @@ let titles: string[] = [] const titlesStates = new Map() - $: getClient() + $: void getClient() .findAll( tags.class.TagReference, { @@ -427,7 +428,7 @@ doProcessing = true if (elements.length > 0 && expertRefs.length > 0) { setTimeout(() => { - updateTagsList( + void updateTagsList( elements, expertRefs.filter((it) => titlesStates.get(prepareTitle(it.title.toLowerCase())) ?? true) ).then(() => { diff --git a/plugins/setting-resources/src/components/ClassAttributes.svelte b/plugins/setting-resources/src/components/ClassAttributes.svelte index 39b62951a4..e64ad58e98 100644 --- a/plugins/setting-resources/src/components/ClassAttributes.svelte +++ b/plugins/setting-resources/src/components/ClassAttributes.svelte @@ -120,8 +120,10 @@ } const handleSelect = async (event: CustomEvent): Promise => { selected = event.detail as AnyAttribute - const exist = (await client.findOne(selected.attributeOf, { [selected.name]: { $exists: true } })) !== undefined - $settingsStore = { id: selected._id, component: EditAttribute, props: { attribute: selected, exist, disabled } } + if (selected != null) { + const exist = (await client.findOne(selected.attributeOf, { [selected.name]: { $exists: true } })) !== undefined + $settingsStore = { id: selected._id, component: EditAttribute, props: { attribute: selected, exist, disabled } } + } } onDestroy(() => { if (selected !== undefined) clearSettingsStore() diff --git a/plugins/tracker-resources/src/components/EditRelatedTargets.svelte b/plugins/tracker-resources/src/components/EditRelatedTargets.svelte index 4d01960df4..c561e3f6ec 100644 --- a/plugins/tracker-resources/src/components/EditRelatedTargets.svelte +++ b/plugins/tracker-resources/src/components/EditRelatedTargets.svelte @@ -15,7 +15,8 @@ tracker.class.RelatedIssueTarget, {}, (res) => { - targets = res.toSorted((a, b) => a.rule.kind.localeCompare(b.rule.kind)) + res.sort((a, b) => a.rule.kind.localeCompare(b.rule.kind)) + targets = res }, { lookup: { diff --git a/plugins/tracker-resources/src/components/templates/EditIssueTemplate.svelte b/plugins/tracker-resources/src/components/templates/EditIssueTemplate.svelte index ce2f909ef7..cddb93e4d0 100644 --- a/plugins/tracker-resources/src/components/templates/EditIssueTemplate.svelte +++ b/plugins/tracker-resources/src/components/templates/EditIssueTemplate.svelte @@ -69,7 +69,9 @@ { _id }, async (result) => { ;[template] = result - title = template.title + if (template != null) { + title = template.title + } currentProject = template.$lookup?.space }, { lookup: { space: tracker.class.Project, labels: tags.class.TagElement } }