diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index ed2669cf5..9b6fdf714 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -71,7 +71,7 @@ interface Props { stagedAttachments: Array; clearAttachments: () => any; removeAttachment: (toRemove: AttachmentType) => void; - onChoseAttachments: (newAttachments: FileList) => void; + onChoseAttachments: (newAttachments: Array) => void; } interface State { @@ -642,7 +642,15 @@ export class SessionCompositionBox extends React.Component { private async onChoseAttachment() { // Build attachments list - const attachmentsFileList = this.fileInput.current?.files; + let attachmentsFileList = null; + + // this is terrible, but we have to reset the input value manually. + // otherwise, the user won't be able to select two times the same file for example. + if (this.fileInput.current?.files) { + attachmentsFileList = Array.from(this.fileInput.current.files); + this.fileInput.current.files = null; + this.fileInput.current.value = ''; + } if (!attachmentsFileList || attachmentsFileList.length === 0) { return; } diff --git a/ts/components/session/conversation/SessionConversation.tsx b/ts/components/session/conversation/SessionConversation.tsx index 3ce7954a4..e32b3a1a2 100644 --- a/ts/components/session/conversation/SessionConversation.tsx +++ b/ts/components/session/conversation/SessionConversation.tsx @@ -958,7 +958,7 @@ export class SessionConversation extends React.Component { }); } - private async onChoseAttachments(attachmentsFileList: FileList) { + private async onChoseAttachments(attachmentsFileList: Array) { if (!attachmentsFileList || attachmentsFileList.length === 0) { return; } @@ -1180,7 +1180,7 @@ export class SessionConversation extends React.Component { e.stopPropagation(); if (e?.dataTransfer?.files && e.dataTransfer.files.length > 0) { - void this.onChoseAttachments(e.dataTransfer.files); + void this.onChoseAttachments(Array.from(e.dataTransfer.files)); e.dataTransfer.clearData(); this.dragCounter = 0; this.setState({ isDraggingFile: false }); diff --git a/ts/receiver/attachments.ts b/ts/receiver/attachments.ts index e8ec4250a..24f03270c 100644 --- a/ts/receiver/attachments.ts +++ b/ts/receiver/attachments.ts @@ -32,7 +32,7 @@ export async function downloadAttachment(attachment: any) { // FIXME "178" test to remove once this is fixed server side. if (!res.response || !res.response.data || res.response.data.length === 178) { - if (res.response.data.length === 178) { + if (res?.response?.data?.length === 178) { window.log.error( 'Data of 178 length corresponds of a 404 returned as 200 by file.getsession.org.' );