desestructured params to download too

This commit is contained in:
Reinaldo Neto 2023-05-15 14:20:31 -03:00
parent 27eacaad9f
commit 07e097000a
2 changed files with 13 additions and 2 deletions

View File

@ -293,7 +293,10 @@ class MessageAudio extends React.Component<IMessageAudioProps, IMessageAudioStat
mimeType: file.audio_type,
messageId
});
const audio = await downloadMediaFile(`${url}?rc_uid=${user.id}&rc_token=${user.token}`, fileSearch.filePath);
const audio = await downloadMediaFile({
url: `${url}?rc_uid=${user.id}&rc_token=${user.token}`,
filePath: fileSearch.filePath
});
await this.sound.loadAsync({ uri: audio });
return this.setState({ loading: false, toDownload: false });
}

View File

@ -68,7 +68,15 @@ export const searchMediaFileAsync = async ({
return { file, filePath };
};
export const downloadMediaFile = async (url: string, filePath: string, downloadResumable?: FileSystem.DownloadResumable) => {
export const downloadMediaFile = async ({
url,
filePath,
downloadResumable
}: {
url: string;
filePath: string;
downloadResumable?: FileSystem.DownloadResumable;
}) => {
let uri = '';
try {
if (downloadResumable) {