This commit is contained in:
Reinaldo Neto 2023-05-19 11:52:22 -03:00
parent 99973c0d28
commit ce67d05852
3 changed files with 4 additions and 18 deletions

View File

@ -154,19 +154,7 @@ class MessageAudio extends React.Component<IMessageAudioProps, IMessageAudioStat
});
this.filePath = fileSearch.filePath;
if (fileSearch?.file?.exists) {
console.log(
'🚀 ~ file: Audio.tsx:157 ~ MessageAudio ~ componentDidMount ~ fileSearch?.file?.exists:',
fileSearch?.file?.exists
);
console.log('🚀 ~ file: Audio.tsx:163 ~ MessageAudio ~ componentDidMount ~ fileSearch.file.uri:', fileSearch.file.uri);
await this.sound
.loadAsync({ uri: fileSearch.file.uri })
.then(value => {
console.log('🚀 ~ file: Audio.tsx:162 ~ MessageAudio ~ awaitthis.sound.loadAsync ~ value:', value);
})
.catch(er => {
console.log('🚀 ~ file: Audio.tsx:158 ~ MessageAudio ~ awaitthis.sound.loadAsync ~ er:', er);
});
await this.sound.loadAsync({ uri: fileSearch.file.uri });
return this.setState({ loading: false });
}
await this.handleAutoDownload();

View File

@ -103,7 +103,7 @@ const ImageContainer = React.memo(
const [loading, setLoading] = useState(false);
const { theme } = useTheme();
const { baseUrl, user } = useContext(MessageContext);
const img = imageUrl || formatAttachmentUrl(newFile.image_url, user.id, user.token, baseUrl);
const img = imageUrl || formatAttachmentUrl(file.image_url, user.id, user.token, baseUrl);
const filePath = useRef('');
useLayoutEffect(() => {
@ -144,7 +144,7 @@ const ImageContainer = React.memo(
setLoading(true);
try {
// The param file.title_link is the one that point to image with best quality, however we still need to test the imageUrl
// And we don't have sure that exists the file.title_link
// And we don't have sure that ever exists the file.title_link
const imgUrl = imageUrl || formatAttachmentUrl(newFile.title_link || newFile.image_url, user.id, user.token, baseUrl);
const imageUri = await downloadMediaFile({
downloadUrl: imgUrl,
@ -160,7 +160,6 @@ const ImageContainer = React.memo(
setToDownload(false);
setLoading(false);
} catch (e) {
console.log('🚀 ~ file: Image.tsx:164 ~ handleDownload ~ e:', e);
setLoading(false);
return setToDownload(true);
}

View File

@ -35,14 +35,12 @@ export function isDownloadActive(mediaType: MediaTypes, messageId: string): bool
export async function cancelDownload(mediaType: MediaTypes, messageId: string): Promise<void> {
const downloadKey = mediaDownloadKey(mediaType, messageId);
if (!isEmpty(downloadQueue[downloadKey])) {
console.log('🚀 ~ file: handleMediaDownload.ts:38 ~ cancelDownload ~ downloadQueue:', downloadQueue);
try {
await downloadQueue[downloadKey].cancel();
} catch {
// Do nothing
}
delete downloadQueue[downloadKey];
console.log('🚀 ~ file: handleMediaDownload.ts:47 ~ cancelDownload ~ downloadQueue:', downloadQueue);
}
}
@ -63,6 +61,7 @@ export function downloadMediaFile({
timeout: 10000,
indicator: true,
overwrite: true,
// The RNFetchBlob just save the file when didn't exist the file:// at the begin of path
path: path.replace('file://', '')
};
downloadQueue[downloadKey] = RNFetchBlob.config(options).fetch('GET', downloadUrl);