diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index c0a85c7d04..89cdeb7dc2 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -76,6 +76,7 @@ export interface StagedLinkPreviewData { export interface StagedAttachmentType extends AttachmentType { file: File; + path?: string; // a bit hacky, but this is the only way to make our sending audio message be playable, this must be used only for those message } export type SendMessageType = { @@ -934,18 +935,22 @@ class SessionCompositionBoxInner extends React.Component<Props, State> { return; } - const file = new File([audioBlob], 'audio-blob'); - + const savedAudioFile = await window.Signal.Migrations.processNewAttachment({ + data: await audioBlob.arrayBuffer(), + isRaw: true, + url: `session-audio-message-${Date.now()}`, + }); const audioAttachment: StagedAttachmentType = { - file, + file: { ...savedAudioFile, path: savedAudioFile.path }, contentType: MIME.AUDIO_MP3, size: audioBlob.size, fileSize: null, screenshot: null, - fileName: 'audio-message', + fileName: 'session-audio-message', thumbnail: null, url: '', isVoiceMessage: true, + path: savedAudioFile.path, }; this.props.sendMessage({ diff --git a/ts/data/data.ts b/ts/data/data.ts index ef0d2ae9b8..4db4afb9b5 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -204,6 +204,7 @@ function _cleanData(data: any): any { // eslint-disable-next-line no-continue continue; } + // eslint-disable no-param-reassign if (_.isFunction(value.toNumber)) { // eslint-disable-next-line no-param-reassign @@ -214,16 +215,12 @@ function _cleanData(data: any): any { // tslint:disable-next-line: no-dynamic-delete delete data[key]; } else if (Array.isArray(value)) { - // eslint-disable-next-line no-param-reassign data[key] = value.map(_cleanData); } else if (_.isObject(value) && value instanceof File) { - // eslint-disable-next-line no-param-reassign data[key] = { name: value.name, path: value.path, size: value.size, type: value.type }; } else if (_.isObject(value)) { - // eslint-disable-next-line no-param-reassign data[key] = _cleanData(value); } else if (_.isBoolean(value)) { - // eslint-disable-next-line no-param-reassign data[key] = value ? 1 : 0; } else if ( typeof value !== 'string' &&