fix: Make sure to always update card description when navigating awayfix

fix #5254
fix #2705

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-11-12 12:22:42 +01:00
parent ffe8aa55d0
commit f8f81af3f8
2 changed files with 21 additions and 5 deletions

View File

@@ -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() {

View File

@@ -186,17 +186,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()
},
@@ -206,6 +215,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')) {
@@ -286,6 +299,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