From b227b31e560dbc5d68203a0611fef660cdebc508 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 19 Dec 2024 21:22:01 +0000 Subject: [PATCH 1/2] Revert "Add iOS hack to fix cropper failing to show (#7191)" This reverts commit 25d20c6395a093a6cfc6aed4d08469f7f128f358. --- src/screens/Onboarding/StepProfile/index.tsx | 6 +----- src/view/com/util/UserAvatar.tsx | 6 +----- src/view/com/util/UserBanner.tsx | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/screens/Onboarding/StepProfile/index.tsx b/src/screens/Onboarding/StepProfile/index.tsx index f8f6ecf4ed..73472ec332 100644 --- a/src/screens/Onboarding/StepProfile/index.tsx +++ b/src/screens/Onboarding/StepProfile/index.tsx @@ -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, @@ -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, diff --git a/src/view/com/util/UserAvatar.tsx b/src/view/com/util/UserAvatar.tsx index db35776afc..dbd68f8ef5 100644 --- a/src/view/com/util/UserAvatar.tsx +++ b/src/view/com/util/UserAvatar.tsx @@ -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' @@ -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, diff --git a/src/view/com/util/UserBanner.tsx b/src/view/com/util/UserBanner.tsx index 12f52c29ef..7e71a04e9f 100644 --- a/src/view/com/util/UserBanner.tsx +++ b/src/view/com/util/UserBanner.tsx @@ -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' @@ -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', From 33bc0b4de464bddd055e63565f0b51002a7030ec Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 19 Dec 2024 21:33:53 +0000 Subject: [PATCH 2/2] Proper fix --- .../react-native-image-crop-picker+0.41.6.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 patches/react-native-image-crop-picker+0.41.6.patch diff --git a/patches/react-native-image-crop-picker+0.41.6.patch b/patches/react-native-image-crop-picker+0.41.6.patch new file mode 100644 index 0000000000..7017ac80ea --- /dev/null +++ b/patches/react-native-image-crop-picker+0.41.6.patch @@ -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; + } +