Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(attachments): Convert FileList to array for FireFox #5656

Merged
merged 1 commit into from
Jan 2, 2024
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
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 { 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 @@
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 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
Loading