fix: download gif files (#5445)

* fix: download gif files

* add test for gif extension

* fix the gif animations at android devices

* remove the space

Co-authored-by: atulsingh98 <atulsingh.17is@saividya.ac.in>
This commit is contained in:
Reinaldo Neto 2024-01-03 17:48:58 -03:00 committed by GitHub
parent 86a9f4f890
commit 2dc52b26b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -380,6 +380,7 @@ dependencies {
androidTestImplementation('com.wix:detox:+')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.facebook.soloader:soloader:0.10.4'
implementation 'com.facebook.fresco:animated-gif:2.5.0'
}
if (isNewArchitectureEnabled()) {

View File

@ -55,4 +55,15 @@ describe('Test the getFilename', () => {
const filename = getFilename({ type: 'image', mimeType: image_type, title, url: image_url });
expect(filename).toBe('help-image-url.png');
});
it('returns the filename with the gif extension from a gif sent by tenor/giphy', () => {
const { image_type, image_url, title } = {
title: undefined,
image_url: 'https://media4.giphy.com/media/bGtO3RlAPHkeQ/giphy.gif',
image_type: undefined
};
const filename = getFilename({ type: 'image', mimeType: image_type, title, url: image_url });
expect(filename).toBe('giphy.gif');
});
});

View File

@ -68,6 +68,10 @@ export const getFilename = ({
};
const getExtension = (type: MediaTypes, mimeType?: string, url?: string) => {
// support url with gif extension and mimetype undefined, ex.: using the app tenor and giphy.
if (url?.split('.').pop() === 'gif') {
return 'gif';
}
if (!mimeType) {
return defaultType[type];
}