Skip to content

Commit

Permalink
[PAY-2859] Fix bugs in edit app flow (#8320)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson committed May 2, 2024
1 parent 465061b commit 3586f41
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/common/src/api/developerApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ const developerAppsApi = createApi({

await sdk.developerApps.updateDeveloperApp({
appApiKey: apiKey,
name: name,
description: description,
imageUrl: imageUrl,
name,
description,
imageUrl,
userId: encodedUserId
})

return {}
return { name, description, imageUrl, apiKey }
},
options: {
idArgKey: 'name',
Expand Down
10 changes: 8 additions & 2 deletions packages/web/src/components/preload-image/PreloadImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ const PreloadImage = ({
alt = '',
asBackground = false,
preloaded = false,
className
className,
height,
width
}: {
src: string
alt?: string
asBackground?: boolean
preloaded?: boolean
className?: string
height?: string
width?: string
}) => {
const [isLoaded, setIsLoaded] = useState(preloaded)
useEffect(() => {
Expand All @@ -33,13 +37,15 @@ const PreloadImage = ({
return asBackground ? (
<div
className={cn(styles.img, className, { [styles.isLoaded]: isLoaded })}
style={{ backgroundImage: `url(${src})` }}
style={{ backgroundImage: `url(${src})`, height, width }}
/>
) : (
<img
src={src}
className={cn(styles.img, className, { [styles.isLoaded]: isLoaded })}
alt={alt}
height={height}
width={width}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
PopupMenuItem
} from '@audius/harmony'

import PreloadImage from 'components/preload-image/PreloadImage'

import styles from './AuthorizedAppListItem.module.css'
import { AuthorizedAppPageProps, AuthorizedAppsPages } from './types'

Expand Down Expand Up @@ -59,7 +61,7 @@ export const AuthorizedAppListItem = (props: AuthorizedAppListItemProps) => {
<li className={styles.listItem}>
<span className={styles.listItemImage}>
{imageUrl ? (
<img src={imageUrl} />
<PreloadImage src={imageUrl} />
) : (
<IconEmbed color='subdued' size='2xl' />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
PopupMenuItem
} from '@audius/harmony'

import PreloadImage from 'components/preload-image/PreloadImage'

import styles from './DeveloperAppListItem.module.css'
import { CreateAppPageProps, CreateAppsPages } from './types'

Expand Down Expand Up @@ -59,7 +61,7 @@ export const DeveloperAppListItem = (props: DeveloperAppListItemProps) => {
<li className={styles.listItem}>
<span className={styles.listItemImage}>
{imageUrl ? (
<img src={imageUrl} />
<PreloadImage src={imageUrl} />
) : (
<IconEmbed color='subdued' size='2xl' />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { toFormikValidationSchema } from 'zod-formik-adapter'
import { make, useRecord } from 'common/store/analytics/actions'
import { Divider } from 'components/divider'
import { TextAreaField, TextField } from 'components/form-fields'
import PreloadImage from 'components/preload-image/PreloadImage'
import Toast from 'components/toast/Toast'
import { MountPlacement } from 'components/types'
import { copyToClipboard } from 'utils/clipboardUtil'
Expand Down Expand Up @@ -47,7 +48,7 @@ const messages = {
const ImageField = ({ name }: { name: string }) => {
const [{ value }] = useField(name)
return value ? (
<img src={value} height='136' width='136' />
<PreloadImage src={value} width='100%' />
) : (
<Flex
w='100%'
Expand Down Expand Up @@ -137,8 +138,14 @@ export const EditAppPage = (props: EditAppPageProps) => {
<Flex gap='m' direction='column'>
<Flex gap='m' alignItems='center'>
<Flex
borderRadius='xs'
css={{ overflow: 'hidden', alignSelf: 'stretch' }}
borderRadius='l'
css={{
overflow: 'hidden',
alignSelf: 'stretch',
width: 138,
maxWidth: 138,
height: 138
}}
flex={'1 1 auto'}
>
<ImageField name='imageUrl' />
Expand Down

0 comments on commit 3586f41

Please sign in to comment.