about summary refs log tree commit diff
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-12-19 21:47:00 +0000
committerGitHub <noreply@github.com>2024-12-19 21:47:00 +0000
commit10981eec50a8e744e4878d2efbb39fa7847ad4d1 (patch)
treebae5333e4322b4cdbf5a1decda04d361ab8ca21a
parentfb920f89d1afd091ab336d8fc8975607787c9a27 (diff)
downloadvoidsky-10981eec50a8e744e4878d2efbb39fa7847ad4d1.tar.zst
Proper fix for iOS cropper being stuck (#7194)
* Revert "Add iOS hack to fix cropper failing to show (#7191)"

This reverts commit 25d20c6395a093a6cfc6aed4d08469f7f128f358.

* Proper fix
-rw-r--r--patches/react-native-image-crop-picker+0.41.6.patch14
-rw-r--r--src/screens/Onboarding/StepProfile/index.tsx6
-rw-r--r--src/view/com/util/UserAvatar.tsx6
-rw-r--r--src/view/com/util/UserBanner.tsx6
4 files changed, 17 insertions, 15 deletions
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 000000000..7017ac80e
--- /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;
+     }
+     
diff --git a/src/screens/Onboarding/StepProfile/index.tsx b/src/screens/Onboarding/StepProfile/index.tsx
index f8f6ecf4e..73472ec33 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 db35776af..dbd68f8ef 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 12f52c29e..7e71a04e9 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',