diff --git a/src/FilesSidebarTabApp.vue b/src/FilesSidebarTabApp.vue
index 0a53b7957c8..149389d20f5 100644
--- a/src/FilesSidebarTabApp.vue
+++ b/src/FilesSidebarTabApp.vue
@@ -43,6 +43,7 @@
+
@@ -62,6 +63,7 @@ import { signalingKill } from './utils/webrtc/index'
import { getCurrentUser } from '@nextcloud/auth'
import { loadState } from '@nextcloud/initial-state'
import Axios from '@nextcloud/axios'
+import UploadEditor from './components/UploadEditor'
import CallButton from './components/TopBar/CallButton'
import ChatView from './components/ChatView'
import duplicateSessionHandler from './mixins/duplicateSessionHandler'
@@ -75,6 +77,7 @@ export default {
components: {
CallButton,
ChatView,
+ UploadEditor,
},
mixins: [
diff --git a/src/components/UploadEditor.vue b/src/components/UploadEditor.vue
index 00ca6a0d950..bd376dd154a 100644
--- a/src/components/UploadEditor.vue
+++ b/src/components/UploadEditor.vue
@@ -80,12 +80,6 @@ export default {
Plus,
},
- data() {
- return {
- modalDismissed: false,
- }
- },
-
computed: {
token() {
return this.$store.getters.getToken()
@@ -102,12 +96,8 @@ export default {
return []
},
- showUploadEditor() {
- return this.$store.getters.showUploadEditor
- },
-
showModal() {
- return this.showUploadEditor && !this.modalDismissed
+ return !!this.currentUploadId
},
addMoreAriaLabel() {
@@ -121,10 +111,6 @@ export default {
this.focus()
}
},
-
- currentUploadId() {
- this.modalDismissed = false
- },
},
methods: {
@@ -135,12 +121,11 @@ export default {
},
handleDismiss() {
- this.modalDismissed = true
+ this.$store.dispatch('discardUpload', this.currentUploadId)
},
handleUpload() {
this.$store.dispatch('uploadFiles', this.currentUploadId)
- this.modalDismissed = true
},
/**
* Clicks the hidden file input when clicking the correspondent ActionButton,
diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js
index 85acf4ef6d1..8086bb0bebd 100644
--- a/src/store/fileUploadStore.js
+++ b/src/store/fileUploadStore.js
@@ -35,7 +35,6 @@ const state = {
uploads: {
},
currentUploadId: undefined,
- showUploadEditor: false,
}
const getters = {
@@ -93,10 +92,6 @@ const getters = {
currentUploadId: (state) => {
return state.currentUploadId
},
-
- showUploadEditor: (state) => {
- return state.showUploadEditor
- },
}
const mutations = {
@@ -174,11 +169,6 @@ const mutations = {
state.currentUploadId = currentUploadId
},
- // Shows hides the upload editor
- showUploadEditor(state, show) {
- state.showUploadEditor = show
- },
-
removeFileFromSelection(state, fileId) {
const uploadId = state.currentUploadId
for (const key in state.uploads[uploadId].files) {
@@ -187,6 +177,10 @@ const mutations = {
}
}
},
+
+ discardUpload(state, uploadId) {
+ Vue.delete(state.uploads, uploadId)
+ },
}
const actions = {
@@ -194,8 +188,6 @@ const actions = {
initialiseUpload({ commit, dispatch }, { uploadId, token, files }) {
// Set last upload id
commit('setCurrentUploadId', uploadId)
- // Show upload editor
- commit('showUploadEditor', true)
files.forEach(file => {
// Get localurl for previews
@@ -210,12 +202,29 @@ const actions = {
})
},
+ /**
+ * Discards an upload
+ * @param {object} param0 Commit and state
+ * @param {object} uploadId The unique uploadId
+ */
+ discardUpload({ commit, state, getters }, uploadId) {
+ if (state.currentUploadId === uploadId) {
+ commit('setCurrentUploadId', undefined)
+ }
+
+ commit('discardUpload', { uploadId })
+ },
+
/**
* Uploads the files to the root directory of the user
* @param {object} param0 Commit, state and getters
* @param {object} uploadId The unique uploadId
*/
async uploadFiles({ commit, dispatch, state, getters }, uploadId) {
+ if (state.currentUploadId === uploadId) {
+ commit('setCurrentUploadId', undefined)
+ }
+
EventBus.$emit('uploadStart')
// Tag the previously indexed files and add the temporary messages to the