Skip to content

Commit

Permalink
fix(files): Show error message if drag-and-drop upload fails
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Nov 27, 2023
1 parent e30ce44 commit c91cdb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions apps/files/src/components/DragAndDropNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<script lang="ts">
import type { Upload } from '@nextcloud/upload'
import { showSuccess } from '@nextcloud/dialogs'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import { getUploader } from '@nextcloud/upload'
import { defineComponent } from 'vue'
Expand Down Expand Up @@ -105,8 +105,13 @@ export default defineComponent({

// Start upload
logger.debug(`Uploading files to ${this.currentFolder.path}`)
const promises = [...event.dataTransfer.files].map((file: File) => {
return uploader.upload(file.name, file) as Promise<Upload>
const promises = [...event.dataTransfer.files].map(async (file: File) => {
try {
return await uploader.upload(file.name, file)
} catch (e) {
showError(t('files', 'Uploading "{filename}" failed', { filename: file.name }))
throw e
}
})

// Process finished uploads
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export default Vue.extend({

// Define current directory children
// TODO: make it more official
Vue.set(folder, '_children', contents.map(node => node.fileid))
this.$set(folder, '_children', contents.map(node => node.fileid))

// If we're in the root dir, define the root
if (dir === '/') {
Expand Down

0 comments on commit c91cdb2

Please sign in to comment.