@@ -90,7 +90,9 @@ import AttachmentList from './AttachmentList.vue'
9090import { NcActions , NcActionButton , NcModal } from ' @nextcloud/vue'
9191import { formatFileSize } from ' @nextcloud/files'
9292import { generateUrl } from ' @nextcloud/router'
93+ import { showWarning } from ' @nextcloud/dialogs'
9394import PaperclipIcon from ' vue-material-design-icons/Paperclip.vue'
95+ import { mapState } from ' vuex'
9496
9597const markdownIt = new MarkdownIt ({
9698 linkify: true ,
@@ -152,6 +154,9 @@ export default {
152154 }
153155 },
154156 computed: {
157+ ... mapState ({
158+ hasCardSaveError : (state ) => state .hasCardSaveError ,
159+ }),
155160 mimetypeForAttachment () {
156161 return (mimetype ) => {
157162 const url = OC .MimeType .getIconUrl (mimetype)
@@ -302,15 +307,31 @@ export default {
302307 return
303308 }
304309 this .descriptionSaving = true
305- if (this .card .id !== undefined ) {
306- await this .$store .dispatch (' updateCardDesc' , { ... this .card , description: this .description })
310+ try {
311+ if (this .card .id !== undefined ) {
312+ await this .$store .dispatch (' updateCardDesc' , { ... this .card , description: this .description })
313+ }
314+ this .$emit (' change' , this .description )
315+ this .descriptionLastEdit = 0
316+ this .$store .commit (' setHasCardSaveError' , false )
317+ } catch (e) {
318+ this .$store .commit (' setHasCardSaveError' , true )
319+ showWarning (t (' deck' , ' Could not save description' ), { timeout: 2500 })
320+ console .error (e)
321+
322+ // Retry of network error
323+ if ([' ERR_NETWORK' , ' ETIMEDOUT' ].includes (e .code )) {
324+ this .setSaveTimeout ()
325+ }
326+ } finally {
327+ this .descriptionSaving = false
307328 }
308- this .$emit (' change' , this .description )
309- this .descriptionLastEdit = 0
310- this .descriptionSaving = false
311329 },
312330 updateDescription () {
313331 this .descriptionLastEdit = Date .now ()
332+ this .setSaveTimeout ()
333+ },
334+ setSaveTimeout () {
314335 clearTimeout (this .descriptionSaveTimeout )
315336 this .descriptionSaveTimeout = setTimeout (async () => {
316337 await this .saveDescription ()
0 commit comments