Skip to content

Commit 3f39605

Browse files
luka-nextcloudbackportbot[bot]
authored andcommitted
fix: add retry and show warning on description saving error
Signed-off-by: Luka Trovic <luka@nextcloud.com> [skip ci]
1 parent 3114648 commit 3f39605

3 files changed

Lines changed: 35 additions & 6 deletions

File tree

src/components/card/CardSidebar.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ import HomeIcon from 'vue-material-design-icons/Home.vue'
9696
import CommentIcon from 'vue-material-design-icons/Comment.vue'
9797
import ActivityIcon from 'vue-material-design-icons/LightningBolt.vue'
9898
99-
import { showError } from '@nextcloud/dialogs'
99+
import { showError, showWarning } from '@nextcloud/dialogs'
100100
import { getLocale } from '@nextcloud/l10n'
101101
import CardMenuEntries from '../cards/CardMenuEntries.vue'
102102
@@ -190,6 +190,10 @@ export default {
190190
},
191191
192192
closeSidebar() {
193+
if (this.hasCardSaveError) {
194+
showWarning(t('deck', 'Cannot close unsaved card!'))
195+
return
196+
}
193197
this.$router?.push({ name: 'board' })
194198
this.$emit('close')
195199
},

src/components/card/Description.vue

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ import AttachmentList from './AttachmentList.vue'
9090
import { NcActions, NcActionButton, NcModal } from '@nextcloud/vue'
9191
import { formatFileSize } from '@nextcloud/files'
9292
import { generateUrl } from '@nextcloud/router'
93+
import { showWarning } from '@nextcloud/dialogs'
9394
import PaperclipIcon from 'vue-material-design-icons/Paperclip.vue'
95+
import { mapState } from 'vuex'
9496
9597
const 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()

src/store/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default new Vuex.Store({
6767
sidebarShown: false,
6868
currentBoard: null,
6969
currentCard: null,
70+
hasCardSaveError: false,
7071
boards: loadState('deck', 'initialBoards', []),
7172
sharees: [],
7273
assignableUsers: [],
@@ -148,6 +149,9 @@ export default new Vuex.Store({
148149
setFullApp(state, isFullApp) {
149150
Vue.set(state, 'isFullApp', isFullApp)
150151
},
152+
setHasCardSaveError(state, hasCardSaveError) {
153+
Vue.set(state, 'hasCardSaveError', hasCardSaveError)
154+
},
151155
SET_CONFIG(state, { key, value }) {
152156
const [scope, id, configKey] = key.split(':', 3)
153157
let indexExisting = -1

0 commit comments

Comments
 (0)