From 29d5913e8bd673fc9c61bfa141a5952a12348e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sun, 12 Nov 2023 12:22:42 +0100 Subject: [PATCH] fix: Make sure to always update card description when navigating awayfix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #5254 fix #2705 Signed-off-by: Julius Härtl --- src/components/card/CardSidebarTabDetails.vue | 6 ++++-- src/components/card/Description.vue | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/card/CardSidebarTabDetails.vue b/src/components/card/CardSidebarTabDetails.vue index c34eab09d..387298cfa 100644 --- a/src/components/card/CardSidebarTabDetails.vue +++ b/src/components/card/CardSidebarTabDetails.vue @@ -119,8 +119,10 @@ export default { this.initialize() }, methods: { - descriptionChanged(newDesc) { - this.$store.dispatch('updateCardDesc', { ...this.card, description: newDesc }) + async descriptionChanged(newDesc) { + if (newDesc === this.copiedCard.description) { + return + } this.copiedCard.description = newDesc }, async initialize() { diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue index 42a76c095..76c5fbdfe 100644 --- a/src/components/card/Description.vue +++ b/src/components/card/Description.vue @@ -187,17 +187,26 @@ export default { mounted() { this.setupEditor() }, - beforeDestroy() { - this?.editor?.destroy() + async beforeDestroy() { + await this.destroyEditor() }, methods: { async setupEditor() { - this?.editor?.destroy() + await this.destroyEditor() + this.descriptionLastEdit = 0 + this.description = this.card.description this.editor = await window.OCA.Text.createEditor({ el: this.$refs.editor, content: this.card.description, readOnly: !this.canEdit, + onLoaded: () => { + this.descriptionLastEdit = 0 + }, onUpdate: ({ markdown }) => { + if (this.description === markdown) { + this.descriptionLastEdit = 0 + return + } this.description = markdown this.updateDescription() }, @@ -207,6 +216,10 @@ export default { }) }, + async destroyEditor() { + await this.saveDescription() + this?.editor?.destroy() + }, addKeyListeners() { this.$refs.markdownEditor.easymde.codemirror.on('keydown', (a, b) => { if (this.keyExitState === 0 && (b.key === 'Meta' || b.key === 'Alt')) { @@ -287,6 +300,7 @@ export default { return } this.descriptionSaving = true + await this.$store.dispatch('updateCardDesc', { ...this.card, description: this.description }) this.$emit('change', this.description) this.descriptionLastEdit = 0 this.descriptionSaving = false