From 419a81a6c43d0de81fcf3ab63dc47ce68336181e Mon Sep 17 00:00:00 2001 From: Maxim Karmatskikh Date: Fri, 17 Nov 2023 17:13:54 +0100 Subject: [PATCH] UBERF-4229: Save attachment cleaner way Signed-off-by: Maxim Karmatskikh --- .../AttachmentStyleBoxEditor.svelte | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/plugins/attachment-resources/src/components/AttachmentStyleBoxEditor.svelte b/plugins/attachment-resources/src/components/AttachmentStyleBoxEditor.svelte index 7610c41fdb..7117cdd6d2 100644 --- a/plugins/attachment-resources/src/components/AttachmentStyleBoxEditor.svelte +++ b/plugins/attachment-resources/src/components/AttachmentStyleBoxEditor.svelte @@ -20,7 +20,7 @@ import { navigate } from '@hcengineering/ui' import view from '@hcengineering/view' import { getObjectLinkFragment } from '@hcengineering/view-resources' - import { createEventDispatcher, onDestroy } from 'svelte' + import { createEventDispatcher } from 'svelte' import AttachmentStyledBox from './AttachmentStyledBox.svelte' export let object: Doc @@ -74,6 +74,8 @@ return } + descriptionBox.createAttachments() + const old = getAttribute(client, object, key) if (description !== old) { await updateAttribute(client, object, object._class, key, description) @@ -85,11 +87,6 @@ } else { haveUnsavedChanges = false } - - /* - Delayed save can be invoked after dismount. In this case descriptionBox would be null - */ - await descriptionBox?.createAttachments() } let saveTrigger: any @@ -105,17 +102,6 @@ saveTrigger = setTimeout(() => save(saveObject, saveDescription), 2500) } - onDestroy(async () => { - // If change text and use mention link inside TextArea - // there is a case when createAttachments wouldn't be called - // because descriptionBox could be destroyed while - // we are doing await updateAttribute - // In that case it's better to call it from here, although - // I didn't find a way to loose any data. - // Check if no change is inside - await descriptionBox?.createAttachments() - }) - export function isFocused (): boolean { return descriptionBox.isFocused() }