Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper fix for iOS cropper being stuck #7194

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions patches/react-native-image-crop-picker+0.41.6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/node_modules/react-native-image-crop-picker/ios/src/ImageCropPicker.m b/node_modules/react-native-image-crop-picker/ios/src/ImageCropPicker.m
index 9f20973..68d4766 100644
--- a/node_modules/react-native-image-crop-picker/ios/src/ImageCropPicker.m
+++ b/node_modules/react-native-image-crop-picker/ios/src/ImageCropPicker.m
@@ -126,7 +126,8 @@ - (void) setConfiguration:(NSDictionary *)options

- (UIViewController*) getRootVC {
UIViewController *root = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
- while (root.presentedViewController != nil) {
+ while (root.presentedViewController != nil &&
+ !root.presentedViewController.isBeingDismissed) {
root = root.presentedViewController;
}

6 changes: 1 addition & 5 deletions src/screens/Onboarding/StepProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {openCropper} from '#/lib/media/picker'
import {getDataUriSize} from '#/lib/media/util'
import {useRequestNotificationsPermission} from '#/lib/notifications/notifications'
import {logEvent, useGate} from '#/lib/statsig/statsig'
import {isIOS, isNative, isWeb} from '#/platform/detection'
import {isNative, isWeb} from '#/platform/detection'
import {
DescriptionText,
OnboardingControls,
Expand Down Expand Up @@ -181,10 +181,6 @@ export function StepProfile() {
if (!image) return

if (!isWeb) {
if (isIOS) {
// https://github.com/ivpusic/react-native-image-crop-picker/issues/1631
await new Promise(resolve => setTimeout(resolve, 800))
}
image = await openCropper({
mediaType: 'photo',
cropperCircleOverlay: true,
Expand Down
6 changes: 1 addition & 5 deletions src/view/com/util/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import {makeProfileLink} from '#/lib/routes/links'
import {colors} from '#/lib/styles'
import {logger} from '#/logger'
import {isAndroid, isIOS, isNative, isWeb} from '#/platform/detection'
import {isAndroid, isNative, isWeb} from '#/platform/detection'
import {precacheProfile} from '#/state/queries/profile'
import {HighPriorityImage} from '#/view/com/util/images/Image'
import {tokens, useTheme} from '#/alf'
Expand Down Expand Up @@ -319,10 +319,6 @@ let EditableUserAvatar = ({
}

try {
if (isIOS) {
// https://github.com/ivpusic/react-native-image-crop-picker/issues/1631
await new Promise(resolve => setTimeout(resolve, 800))
}
const croppedImage = await openCropper({
mediaType: 'photo',
cropperCircleOverlay: true,
Expand Down
6 changes: 1 addition & 5 deletions src/view/com/util/UserBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import {colors} from '#/lib/styles'
import {useTheme} from '#/lib/ThemeContext'
import {logger} from '#/logger'
import {isAndroid, isIOS, isNative} from '#/platform/detection'
import {isAndroid, isNative} from '#/platform/detection'
import {EventStopper} from '#/view/com/util/EventStopper'
import {tokens, useTheme as useAlfTheme} from '#/alf'
import {useSheetWrapper} from '#/components/Dialog/sheet-wrapper'
Expand Down Expand Up @@ -68,10 +68,6 @@ export function UserBanner({
}

try {
if (isIOS) {
// https://github.com/ivpusic/react-native-image-crop-picker/issues/1631
await new Promise(resolve => setTimeout(resolve, 800))
}
onSelectNewBanner?.(
await openCropper({
mediaType: 'photo',
Expand Down
Loading