Skip to content

Commit

Permalink
fix(attachments): Convert FileList to array
Browse files Browse the repository at this point in the history
Firefox does not have FileList.forEach

Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst authored and backportbot-nextcloud[bot] committed Jan 2, 2024
1 parent a05a13f commit 3cb5c1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
31 changes: 18 additions & 13 deletions src/components/Editor/Attachments/AttachmentsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import Plus from 'vue-material-design-icons/Plus.vue'
import { generateUrl } from '@nextcloud/router'
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
import logger from '../../../utils/logger.js'
import {
uploadLocalAttachment,
getFileInfo,
Expand Down Expand Up @@ -172,20 +173,24 @@ export default {
await createFolder(this.attachmentsFolder, this.currentUser.userId)
this.folderCreated = true
}
const attachments = await uploadLocalAttachment(this.attachmentsFolder, e, this.currentUser.dav, this.attachments)
// TODO do not share file, move to PHP
attachments.map(async attachment => {
const data = await getFileInfo(`${this.attachmentsFolder}/${attachment.path}`, this.currentUser.dav)
const davRes = await parseXML(data)
const davRespObj = davRes?.multistatus?.response[0]?.propstat?.prop
davRespObj.fileName = attachment.path
davRespObj.url = generateUrl(`/f/${davRespObj.fileid}`)
davRespObj.value = davRespObj.url
this.addAttachmentWithProperty(this.calendarObjectInstance, davRespObj)
})
e.target.value = ''
try {
const attachments = await uploadLocalAttachment(this.attachmentsFolder, Array.from(e.target.files), this.currentUser.dav, this.attachments)
// TODO do not share file, move to PHP
attachments.map(async attachment => {
const data = await getFileInfo(`${this.attachmentsFolder}/${attachment.path}`, this.currentUser.dav)
const davRes = await parseXML(data)
const davRespObj = davRes?.multistatus?.response[0]?.propstat?.prop
davRespObj.fileName = attachment.path
davRespObj.url = generateUrl(`/f/${davRespObj.fileid}`)
davRespObj.value = davRespObj.url
this.addAttachmentWithProperty(this.calendarObjectInstance, davRespObj)
})
e.target.value = ''
} catch (error) {
logger.error('Could not upload attachment(s)', { error })
showError(t('calendar', 'Could not upload attachment(s)'))
}

Check warning on line 193 in src/components/Editor/Attachments/AttachmentsList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Attachments/AttachmentsList.vue#L192-L193

Added lines #L192 - L193 were not covered by tests
},
getIcon(mime) {
return OC.MimeType.getIconUrl(mime)
Expand Down
3 changes: 1 addition & 2 deletions src/services/attachmentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ const createFolder = async function(folderName, userId) {
})
}

const uploadLocalAttachment = async function(folder, event, dav, componentAttachments) {
const files = event.target.files
const uploadLocalAttachment = async function(folder, files, dav, componentAttachments) {

Check warning on line 100 in src/services/attachmentService.js

View check run for this annotation

Codecov / codecov/patch

src/services/attachmentService.js#L100

Added line #L100 was not covered by tests
const attachments = []
const promises = []

Expand Down

0 comments on commit 3cb5c1c

Please sign in to comment.