Rename image size constants and require them as params

POST_IMG_MAX no longer described post images, so rename it to the
semantically accurate pair: POST_IMG_MAX_SIZE (4000px/2MB, post images
and pasted URLs) and PROFILE_IMAGES_MAX_SIZE (2000px/1MB, avatars,
banners, onboarding, link thumbnails).

Drop the constant defaults from compressImage, compressIfNeeded, and
getResizedDimensions; callers now pass the appropriate max config object
directly so the size policy lives at the call site. Web avatar/banner
edits now use PROFILE_IMAGES_MAX_SIZE, matching the native profile path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Eric Bailey
2026-06-02 11:44:52 -05:00
parent e14d559a13
commit 736acb8a61
14 changed files with 72 additions and 51 deletions
+4 -1
View File
@@ -17,6 +17,7 @@ import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
import {useQueryClient} from '@tanstack/react-query'
import {PROFILE_IMAGES_MAX_SIZE} from '#/lib/constants'
import {useHaptics} from '#/lib/haptics'
import {
useCameraPermission,
@@ -394,6 +395,7 @@ let EditableUserAvatar = ({
await openCamera({
aspect: [1, 1],
}),
PROFILE_IMAGES_MAX_SIZE,
),
)
}, [onSelectNewAvatar, requestCameraAccessIfNeeded])
@@ -422,6 +424,7 @@ let EditableUserAvatar = ({
shape: circular ? 'circle' : 'rectangle',
aspectRatio: 1,
}),
PROFILE_IMAGES_MAX_SIZE,
),
)
} else {
@@ -448,7 +451,7 @@ let EditableUserAvatar = ({
const onChangeEditImage = useCallback(
async (image: ComposerImage) => {
const compressed = await compressImage(image)
const compressed = await compressImage(image, PROFILE_IMAGES_MAX_SIZE)
onSelectNewAvatar(compressed)
},
[onSelectNewAvatar],