Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/card/CardSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ import HomeIcon from 'vue-material-design-icons/Home.vue'
import CommentIcon from 'vue-material-design-icons/Comment.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 CardMenuEntries from '../cards/CardMenuEntries.vue'

Expand Down Expand Up @@ -190,6 +190,10 @@ export default {
},

closeSidebar() {
if (this.hasCardSaveError) {
showWarning(t('deck', 'Cannot close unsaved card!'))
return
}
this.$router?.push({ name: 'board' })
this.$emit('close')
},
Expand Down
31 changes: 26 additions & 5 deletions src/components/card/Description.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ import AttachmentList from './AttachmentList.vue'
import { NcActions, NcActionButton, NcModal } from '@nextcloud/vue'
import { formatFileSize } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import { showWarning } from '@nextcloud/dialogs'
import PaperclipIcon from 'vue-material-design-icons/Paperclip.vue'
import { mapState } from 'vuex'

const markdownIt = new MarkdownIt({
linkify: true,
Expand Down Expand Up @@ -152,6 +154,9 @@ export default {
}
},
computed: {
...mapState({
hasCardSaveError: (state) => state.hasCardSaveError,
}),
mimetypeForAttachment() {
return (mimetype) => {
const url = OC.MimeType.getIconUrl(mimetype)
Expand Down Expand Up @@ -302,15 +307,31 @@ export default {
return
}
this.descriptionSaving = true
if (this.card.id !== undefined) {
await this.$store.dispatch('updateCardDesc', { ...this.card, description: this.description })
try {
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() {
this.descriptionLastEdit = Date.now()
this.setSaveTimeout()
},
setSaveTimeout() {
clearTimeout(this.descriptionSaveTimeout)
this.descriptionSaveTimeout = setTimeout(async () => {
await this.saveDescription()
Expand Down
4 changes: 4 additions & 0 deletions src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default new Vuex.Store({
sidebarShown: false,
currentBoard: null,
currentCard: null,
hasCardSaveError: false,
boards: loadState('deck', 'initialBoards', []),
sharees: [],
assignableUsers: [],
Expand Down Expand Up @@ -148,6 +149,9 @@ export default new Vuex.Store({
setFullApp(state, isFullApp) {
Vue.set(state, 'isFullApp', isFullApp)
},
setHasCardSaveError(state, hasCardSaveError) {
Vue.set(state, 'hasCardSaveError', hasCardSaveError)
},
SET_CONFIG(state, { key, value }) {
const [scope, id, configKey] = key.split(':', 3)
let indexExisting = -1
Expand Down