Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Fix edit images (#2302)
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptype authored Nov 23, 2022
1 parent 2d17c4a commit fed67d3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 7 additions & 2 deletions packages/mobile/src/components/core/FormImageInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useState } from 'react'
import { useCallback, useMemo, useState } from 'react'

import { useField } from 'formik'
import type { ImageStyle, ViewStyle } from 'react-native'
Expand Down Expand Up @@ -89,6 +89,11 @@ export const FormImageInput = ({

const isDefaultImage = /imageCoverPhotoBlank/.test(url)

const source = useMemo(
() => ({ uri: isDefaultImage ? `https://audius.co/${url}` : url }),
[isDefaultImage, url]
)

return (
<Pressable
style={[style, stylesProp?.root]}
Expand All @@ -97,7 +102,7 @@ export const FormImageInput = ({
onPressOut={handlePressOut}
>
<DynamicImage
source={{ uri: isDefaultImage ? `https://audius.co/${url}` : url }}
source={source}
styles={{
root: [styles.imageContainer, stylesProp?.imageContainer],
image: [styles.image, stylesProp?.image]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export const EditProfileScreen = () => {
tiktok_handle,
website,
donation,
cover_photo: { url: coverPhotoSource[0].uri },
profile_picture: { url: imageSource[0].uri }
cover_photo: { url: coverPhotoSource[1].uri },
profile_picture: { url: imageSource[2].uri }
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const EditExistingTrackScreen = () => {
const initialValues = {
...track,
artwork: null,
trackArtwork: imageSource[0].uri
trackArtwork: imageSource[2].uri
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useState } from 'react'
import { useCallback, useMemo, useState } from 'react'

import { useField } from 'formik'
import { capitalize } from 'lodash'
Expand Down Expand Up @@ -89,10 +89,12 @@ export const PickArtworkField = () => {
launchSelectImageActionSheet(handleImageSelected, secondary)
}, [secondary, setValue])

const source = useMemo(() => ({ uri: trackArtworkUrl }), [trackArtworkUrl])

return (
<View style={styles.root}>
<DynamicImage
source={{ uri: trackArtworkUrl }}
source={source}
onLoad={() => setIsLoading(false)}
style={styles.image}
>
Expand Down

0 comments on commit fed67d3

Please sign in to comment.