Skip to content

Commit 2141bd9

Browse files
feat: live update card description
Signed-off-by: Luka Trovic <luka@nextcloud.com>
1 parent cc2484f commit 2141bd9

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/components/card/Description.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export default {
118118
textAppAvailable: !!window.OCA?.Text?.createEditor,
119119
editor: null,
120120
keyExitState: 0,
121+
descriptionOld: '',
121122
description: '',
122123
markdownIt: null,
123124
descriptionEditing: false,
@@ -172,6 +173,21 @@ export default {
172173
return this.card?.description?.trim?.() !== ''
173174
},
174175
},
176+
watch: {
177+
card(newCard) {
178+
if (newCard.description !== this.descriptionOld) {
179+
clearTimeout(this.descriptionSaveTimeout)
180+
this.descriptionLastEdit = 0
181+
182+
this.descriptionOld = newCard.description
183+
this.description = newCard.description
184+
if (this.editor) {
185+
this.editor.setContent(this.description)
186+
}
187+
showWarning(t('deck', 'The description has been changed by another user.'), { timeout: 3000 })
188+
}
189+
},
190+
},
175191
mounted() {
176192
this.setupEditor()
177193
},
@@ -182,6 +198,7 @@ export default {
182198
async setupEditor() {
183199
await this.destroyEditor()
184200
this.descriptionLastEdit = 0
201+
this.descriptionOld = this.card.description
185202
this.description = this.card.description
186203
this.editor = await window.OCA.Text.createEditor({
187204
el: this.$refs.editor,
@@ -296,6 +313,7 @@ export default {
296313
}
297314
this.$emit('change', this.description)
298315
this.descriptionLastEdit = 0
316+
this.descriptionOld = this.description
299317
this.$store.commit('setHasCardSaveError', false)
300318
} catch (e) {
301319
this.$store.commit('setHasCardSaveError', true)

0 commit comments

Comments
 (0)