Skip to content
Open
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
43 changes: 42 additions & 1 deletion src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div class="message-composer">
<div
class="message-composer"
@dragover.prevent
@drop="onDrop"
@paste="onPaste"

Check failure on line 10 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected no line breaks before closing bracket, but 1 line break found
>
<NcReferencePickerModal
v-if="isPickerAvailable && isPickerOpen"
id="reference-picker"
Expand Down Expand Up @@ -1739,6 +1744,42 @@
return option.email
},

onDrop(event) {
event.preventDefault()

const files = Array.from(event.dataTransfer.files)

if (!files.length) {
return
}

this.bus.emit('on-add-local-files', files)
this.saveDraftDebounced()
},

onPaste(event) {
const files = []

for (const item of event.clipboardData.items) {
if (item.kind === 'file') {
const file = item.getAsFile()

if (file) {
files.push(file)
}
}
}

if (!files.length) {
return
}

event.preventDefault()

this.bus.emit('on-add-local-files', files)
this.saveDraftDebounced()
}

Check failure on line 1781 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma

},
}
</script>
Expand Down
13 changes: 10 additions & 3 deletions src/components/ComposerAttachments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
this.bus.on('on-add-cloud-attachment', this.openAttachementPicker)
this.bus.on('on-add-cloud-attachment-link', this.OpenLinkPicker)
this.bus.on('on-add-message-as-attachment', this.onAddMessageAsAttachment)
this.bus.on('on-add-local-files', this.addLocalFiles)
this.value.map((attachment) => {
this.attachments.push({
id: attachment.id,
Expand Down Expand Up @@ -240,11 +241,15 @@
},

onLocalAttachmentSelected(e) {
return this.addLocalFiles(Array.from(e.target.files))
},

addLocalFiles(files) {
this.uploading = true
// BUG - if choose again - progress lost/ move to complete()
Vue.set(this, 'uploads', {})

const toUpload = sumBy(prop('size'), Object.values(e.target.files))
const toUpload = sumBy(prop('size'), Object.values(files))
const newTotal = toUpload + this.totalSizeOfUpload()
logger.debug('checking upload size limit', {
existingUploads: this.totalSizeOfUpload(),
Expand All @@ -253,7 +258,7 @@
newTotal,
})
if (this.uploadSizeLimit && newTotal > this.uploadSizeLimit) {
this.showAttachmentFileSizeWarning(e.target.files.length)
this.showAttachmentFileSizeWarning(files.length)
this.uploading = false
return
}
Expand Down Expand Up @@ -318,7 +323,7 @@
} catch (error) {
logger.error('Could not upload file', { file, error })
}
}, e.target.files)
}, files)

const done = Promise.all(promises)
.catch((error) => logger.error('could not upload all attachments', { error }))
Expand All @@ -329,6 +334,8 @@
return done
},


Check failure on line 337 in src/components/ComposerAttachments.vue

View workflow job for this annotation

GitHub Actions / NPM lint

More than 1 blank line not allowed

async onAddCloudAttachment(nodes) {
try {
const paths = nodes.map((node) => node.path)
Expand Down
Loading