diff --git a/app/lib/methods/mediaPicker.ts b/app/lib/methods/mediaPicker.ts index a1f0ac132..f3b6e1d23 100644 --- a/app/lib/methods/mediaPicker.ts +++ b/app/lib/methods/mediaPicker.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-redeclare */ import * as FileSystem from 'expo-file-system'; import * as ImagePicker from 'expo-image-picker'; import { PermissionsAndroid } from 'react-native'; @@ -74,7 +73,7 @@ export const pickMultipleImageAndVideoFromLibrary = async (): Promise; -export async function pickImageFromLibrary(base64?: false): Promise; -export async function pickImageFromLibrary( - base64?: boolean -): Promise { +export async function pickImageFromLibrary({ animatedGif = true }: { animatedGif: boolean }): Promise { try { const image = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, - quality: undefined, // to force animated gifs - base64 + quality: animatedGif ? 1 : 0.9, + base64: true }); - if (!image.cancelled) return addAdditionalPropsToFile(image); + if (!image.cancelled) { + const selectedImage = await addAdditionalPropsToFile(image); + return selectedImage; + } return null; } catch (error) { log(error); diff --git a/app/views/ProfileView/index.tsx b/app/views/ProfileView/index.tsx index 0f2eb6c15..dd818e9dc 100644 --- a/app/views/ProfileView/index.tsx +++ b/app/views/ProfileView/index.tsx @@ -345,9 +345,9 @@ class ProfileView extends React.Component try { logEvent(events.PROFILE_PICK_AVATAR); - const response = await pickImageFromLibrary(true); + const response = await pickImageFromLibrary({ animatedGif: false }); if (response) { - this.setAvatar({ url: response.path, data: `data:image/jpeg;base64,${response.data}`, service: 'upload' }); + this.setAvatar({ url: response.path, data: `data:image/jpeg;base64,${response.base64}`, service: 'upload' }); } } catch (error) { logEvent(events.PROFILE_PICK_AVATAR_F); diff --git a/app/views/RoomInfoEditView/index.tsx b/app/views/RoomInfoEditView/index.tsx index 08871547a..67bac6fdc 100644 --- a/app/views/RoomInfoEditView/index.tsx +++ b/app/views/RoomInfoEditView/index.tsx @@ -489,9 +489,9 @@ class RoomInfoEditView extends React.Component { try { - const response = await pickImageFromLibrary(true); + const response = await pickImageFromLibrary({ animatedGif: false }); if (response) { - this.setState({ avatar: { url: response.path, data: `data:image/jpeg;base64,${response.data}`, service: 'upload' } }); + this.setState({ avatar: { url: response.path, data: `data:image/jpeg;base64,${response.base64}`, service: 'upload' } }); } } catch (e) { console.log(e);