fix: add retry and show warning on description saving error
Signed-off-by: Luka Trovic <luka@nextcloud.com> [skip ci]
This commit is contained in:
committed by
backportbot[bot]
parent
31146484ce
commit
3f39605e53
@@ -96,7 +96,7 @@ import HomeIcon from 'vue-material-design-icons/Home.vue'
|
|||||||
import CommentIcon from 'vue-material-design-icons/Comment.vue'
|
import CommentIcon from 'vue-material-design-icons/Comment.vue'
|
||||||
import ActivityIcon from 'vue-material-design-icons/LightningBolt.vue'
|
import ActivityIcon from 'vue-material-design-icons/LightningBolt.vue'
|
||||||
|
|
||||||
import { showError } from '@nextcloud/dialogs'
|
import { showError, showWarning } from '@nextcloud/dialogs'
|
||||||
import { getLocale } from '@nextcloud/l10n'
|
import { getLocale } from '@nextcloud/l10n'
|
||||||
import CardMenuEntries from '../cards/CardMenuEntries.vue'
|
import CardMenuEntries from '../cards/CardMenuEntries.vue'
|
||||||
|
|
||||||
@@ -190,6 +190,10 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
closeSidebar() {
|
closeSidebar() {
|
||||||
|
if (this.hasCardSaveError) {
|
||||||
|
showWarning(t('deck', 'Cannot close unsaved card!'))
|
||||||
|
return
|
||||||
|
}
|
||||||
this.$router?.push({ name: 'board' })
|
this.$router?.push({ name: 'board' })
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ import AttachmentList from './AttachmentList.vue'
|
|||||||
import { NcActions, NcActionButton, NcModal } from '@nextcloud/vue'
|
import { NcActions, NcActionButton, NcModal } from '@nextcloud/vue'
|
||||||
import { formatFileSize } from '@nextcloud/files'
|
import { formatFileSize } from '@nextcloud/files'
|
||||||
import { generateUrl } from '@nextcloud/router'
|
import { generateUrl } from '@nextcloud/router'
|
||||||
|
import { showWarning } from '@nextcloud/dialogs'
|
||||||
import PaperclipIcon from 'vue-material-design-icons/Paperclip.vue'
|
import PaperclipIcon from 'vue-material-design-icons/Paperclip.vue'
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
const markdownIt = new MarkdownIt({
|
const markdownIt = new MarkdownIt({
|
||||||
linkify: true,
|
linkify: true,
|
||||||
@@ -152,6 +154,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
hasCardSaveError: (state) => state.hasCardSaveError,
|
||||||
|
}),
|
||||||
mimetypeForAttachment() {
|
mimetypeForAttachment() {
|
||||||
return (mimetype) => {
|
return (mimetype) => {
|
||||||
const url = OC.MimeType.getIconUrl(mimetype)
|
const url = OC.MimeType.getIconUrl(mimetype)
|
||||||
@@ -302,15 +307,31 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.descriptionSaving = true
|
this.descriptionSaving = true
|
||||||
if (this.card.id !== undefined) {
|
try {
|
||||||
await this.$store.dispatch('updateCardDesc', { ...this.card, description: this.description })
|
if (this.card.id !== undefined) {
|
||||||
|
await this.$store.dispatch('updateCardDesc', { ...this.card, description: this.description })
|
||||||
|
}
|
||||||
|
this.$emit('change', this.description)
|
||||||
|
this.descriptionLastEdit = 0
|
||||||
|
this.$store.commit('setHasCardSaveError', false)
|
||||||
|
} catch (e) {
|
||||||
|
this.$store.commit('setHasCardSaveError', true)
|
||||||
|
showWarning(t('deck', 'Could not save description'), { timeout: 2500 })
|
||||||
|
console.error(e)
|
||||||
|
|
||||||
|
// Retry of network error
|
||||||
|
if (['ERR_NETWORK', 'ETIMEDOUT'].includes(e.code)) {
|
||||||
|
this.setSaveTimeout()
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.descriptionSaving = false
|
||||||
}
|
}
|
||||||
this.$emit('change', this.description)
|
|
||||||
this.descriptionLastEdit = 0
|
|
||||||
this.descriptionSaving = false
|
|
||||||
},
|
},
|
||||||
updateDescription() {
|
updateDescription() {
|
||||||
this.descriptionLastEdit = Date.now()
|
this.descriptionLastEdit = Date.now()
|
||||||
|
this.setSaveTimeout()
|
||||||
|
},
|
||||||
|
setSaveTimeout() {
|
||||||
clearTimeout(this.descriptionSaveTimeout)
|
clearTimeout(this.descriptionSaveTimeout)
|
||||||
this.descriptionSaveTimeout = setTimeout(async () => {
|
this.descriptionSaveTimeout = setTimeout(async () => {
|
||||||
await this.saveDescription()
|
await this.saveDescription()
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export default new Vuex.Store({
|
|||||||
sidebarShown: false,
|
sidebarShown: false,
|
||||||
currentBoard: null,
|
currentBoard: null,
|
||||||
currentCard: null,
|
currentCard: null,
|
||||||
|
hasCardSaveError: false,
|
||||||
boards: loadState('deck', 'initialBoards', []),
|
boards: loadState('deck', 'initialBoards', []),
|
||||||
sharees: [],
|
sharees: [],
|
||||||
assignableUsers: [],
|
assignableUsers: [],
|
||||||
@@ -148,6 +149,9 @@ export default new Vuex.Store({
|
|||||||
setFullApp(state, isFullApp) {
|
setFullApp(state, isFullApp) {
|
||||||
Vue.set(state, 'isFullApp', isFullApp)
|
Vue.set(state, 'isFullApp', isFullApp)
|
||||||
},
|
},
|
||||||
|
setHasCardSaveError(state, hasCardSaveError) {
|
||||||
|
Vue.set(state, 'hasCardSaveError', hasCardSaveError)
|
||||||
|
},
|
||||||
SET_CONFIG(state, { key, value }) {
|
SET_CONFIG(state, { key, value }) {
|
||||||
const [scope, id, configKey] = key.split(':', 3)
|
const [scope, id, configKey] = key.split(':', 3)
|
||||||
let indexExisting = -1
|
let indexExisting = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user