UBER-424: description not saving fix (#3434)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-06-16 10:04:53 +05:00 committed by GitHub
parent 2e142ba194
commit f180ea4b10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Doc, Markup, updateAttribute } from '@hcengineering/core'
import { Class, Doc, Markup, Ref, updateAttribute } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import { createQuery, getAttribute, getClient, KeyedAttribute } from '@hcengineering/presentation'
@ -28,7 +28,8 @@
export let placeholder: IntlString
export let focusIndex = -1
export let updateBacklinks: ((doc: Doc, description: Markup) => void) | undefined = undefined
let _id: Ref<Doc> | undefined = undefined
let _class: Ref<Class<Doc>> | undefined = undefined
const client = getClient()
const queryClient = createQuery()
@ -36,13 +37,20 @@
let description = ''
let doc: Doc | undefined
$: queryClient.query(object._class, { _id: object._id }, async (result) => {
;[doc] = result
if (doc) {
description = getAttribute(client, object, key)
}
})
function checkForNewObject (object: Doc) {
if (object._id !== _id) return true
if (object._class !== _class) return true
return false
}
$: object &&
queryClient.query(object._class, { _id: object._id }, async (result) => {
;[doc] = result
if (doc && checkForNewObject(object)) {
_class = object._class
_id = object._id
description = getAttribute(client, object, key)
}
})
const dispatch = createEventDispatcher()
@ -56,7 +64,7 @@
const old = getAttribute(client, object, key)
if (description !== old) {
updateAttribute(client, object, object._class, key, description)
await updateAttribute(client, object, object._class, key, description)
dispatch('saved', true)
setTimeout(() => {
dispatch('saved', false)

View File

@ -365,7 +365,6 @@
on:blur
on:focus
on:open-document
on:open-document
on:attach={() => {
attach()
}}