Skip to content

fix: limit media size in tweet composer media uploads - [CU-869bga43d] - #240

Merged
AhmedSobhy01 merged 4 commits into
devfrom
fix/limit-media-size
Dec 15, 2025
Merged

fix: limit media size in tweet composer media uploads - [CU-869bga43d]#240
AhmedSobhy01 merged 4 commits into
devfrom
fix/limit-media-size

Conversation

@Exo1i

@Exo1i Exo1i commented Dec 15, 2025

Copy link
Copy Markdown
Member

This pull request introduces file size validation for media uploads in the TweetComposer component, ensuring that images and videos do not exceed specified size limits (5MB for images, 10MB for videos). It also refines permission handling in the useMediaLibrary hook to avoid unnecessary permission prompts and improve user experience. The test suite is updated to mock file system checks and reflect the new logic.

Media upload validation and user feedback:

  • Added file size checks before allowing images or videos to be attached in TweetComposer, displaying alerts if files are too large [1] [2] [3] [4].
  • Introduced expo-file-system/legacy for file size retrieval and a helper function checkFileSize [1] [2].

Test updates:

  • Mocked expo-file-system in tests to simulate file size checks.
  • Updated tests to remove the now-unused allowsEditing property from media picker calls [1] [2].

Permission handling improvements:

  • Improved logic in useMediaLibrary to only request permissions when necessary and prevent repeated prompts, with clearer user feedback on denied permissions [1] [2] [3].

…g an alert with a console warning for denied permissions.
… `allowsEditing` from image picker configurations.
@Exo1i

Exo1i commented Dec 15, 2025

Copy link
Copy Markdown
Member Author

@Exo1i
Exo1i changed the base branch from main to dev December 15, 2025 14:23
im-saif
im-saif previously approved these changes Dec 15, 2025
@github-actions

Copy link
Copy Markdown

Unit Tests Coverage Report

Coverage after merging fix/limit-media-size into dev will be
90.71%
Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src/components/ui
   TweetComposer.tsx75.45%66%65.79%84.42%120–122, 135, 140, 169–170, 170, 170–172, 172, 176, 178, 185–186, 196, 196, 220–222, 235–236, 280, 290–291, 294, 299, 302, 308, 308, 308–309, 309, 309, 316–318, 329, 333–334, 338, 344, 347, 359–361, 373, 377–378, 382, 388, 390, 392, 395, 398, 408, 408–409, 428, 430, 436, 441–442, 462, 467–469, 522–523, 635, 647, 80, 80, 80, 80–81, 83, 83, 83–85
src/hooks
   useMediaLibrary.ts87.64%74.19%100%94.34%31, 55, 62, 68, 72, 78, 8, 80, 80, 90, 95

@AhmedSobhy01
AhmedSobhy01 merged commit 7693061 into dev Dec 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants