Skip to content

Commit 4d4802b

Browse files
srikarparsiOSBotify
authored andcommitted
Merge pull request #87504 from Expensify/revert-86981-claude-useInAppCameraForAttachments
[CP Staging] Revert "fix: use in-app VisionCamera for chat attachments with proper permission handling" (cherry picked from commit 477ef7d) (cherry-picked to staging by mountiny)
1 parent 0acd30e commit 4d4802b

File tree

15 files changed

+3
-348
lines changed

15 files changed

+3
-348
lines changed

assets/images/camera-flip.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

jest/setup.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,3 @@ jest.mock('@src/hooks/useDomainDocumentTitle', () => ({
381381
__esModule: true,
382382
default: jest.fn(),
383383
}));
384-
385-
jest.mock('react-native-vision-camera', () => ({
386-
Camera: 'Camera',
387-
useCameraDevice: jest.fn(() => null),
388-
useCameraFormat: jest.fn(() => null),
389-
useCameraPermission: jest.fn(() => ({hasPermission: false, requestPermission: jest.fn()})),
390-
}));

src/components/AttachmentPicker/AttachmentCamera.tsx

Lines changed: 0 additions & 276 deletions
This file was deleted.

src/components/AttachmentPicker/index.native.tsx

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import CONST from '@src/CONST';
2424
import type {TranslationPaths} from '@src/languages/types';
2525
import type {FileObject, ImagePickerResponse as FileResponse} from '@src/types/utils/Attachment';
2626
import type IconAsset from '@src/types/utils/IconAsset';
27-
import AttachmentCamera from './AttachmentCamera';
28-
import type {CapturedPhoto} from './AttachmentCamera';
27+
import launchCamera from './launchCamera/launchCamera';
2928
import type AttachmentPickerProps from './types';
3029

3130
type LocalCopy = {
@@ -137,10 +136,6 @@ function AttachmentPicker({
137136
const onClosed = useRef<() => void>(() => {});
138137
const popoverRef = useRef(null);
139138

140-
// In-app camera state — uses VisionCamera to keep the app in the foreground during photo capture
141-
const [showAttachmentCamera, setShowAttachmentCamera] = useState(false);
142-
const cameraResolveRef = useRef<((photos?: CapturedPhoto[]) => void) | null>(null);
143-
144139
const {translate} = useLocalize();
145140
const {shouldUseNarrowLayout} = useResponsiveLayout();
146141

@@ -154,43 +149,6 @@ function AttachmentPicker({
154149
[translate],
155150
);
156151

157-
/**
158-
* Launch the in-app camera using VisionCamera.
159-
* Returns a Promise that resolves with the captured photo as an Asset-compatible object,
160-
* or resolves with void if the user closes the camera without capturing.
161-
*/
162-
const launchInAppCamera = useCallback((): Promise<Asset[] | void> => {
163-
return new Promise((resolve) => {
164-
cameraResolveRef.current = (photos?: CapturedPhoto[]) => {
165-
if (!photos || photos.length === 0) {
166-
resolve();
167-
return;
168-
}
169-
const assets: Asset[] = photos.map((photo) => ({
170-
uri: photo.uri,
171-
fileName: photo.fileName,
172-
type: photo.type,
173-
width: photo.width,
174-
height: photo.height,
175-
}));
176-
resolve(assets);
177-
};
178-
setShowAttachmentCamera(true);
179-
});
180-
}, []);
181-
182-
const handleCameraCapture = (photos: CapturedPhoto[]) => {
183-
setShowAttachmentCamera(false);
184-
cameraResolveRef.current?.(photos);
185-
cameraResolveRef.current = null;
186-
};
187-
188-
const handleCameraClose = () => {
189-
setShowAttachmentCamera(false);
190-
cameraResolveRef.current?.();
191-
cameraResolveRef.current = null;
192-
};
193-
194152
/**
195153
* Common image picker handling
196154
*
@@ -343,12 +301,12 @@ function AttachmentPicker({
343301
data.unshift({
344302
icon: icons.Camera,
345303
textTranslationKey: 'attachmentPicker.takePhoto',
346-
pickAttachment: launchInAppCamera,
304+
pickAttachment: () => showImagePicker(launchCamera),
347305
});
348306
}
349307

350308
return data;
351-
}, [icons.Camera, icons.Paperclip, icons.Gallery, showDocumentPicker, shouldHideGalleryOption, shouldHideCameraOption, showImagePicker, launchInAppCamera]);
309+
}, [icons.Camera, icons.Paperclip, icons.Gallery, showDocumentPicker, shouldHideGalleryOption, shouldHideCameraOption, showImagePicker]);
352310

353311
const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({initialFocusedIndex: -1, maxIndex: menuItemData.length - 1, isActive: isVisible});
354312

@@ -570,13 +528,6 @@ function AttachmentPicker({
570528
))}
571529
</View>
572530
</Popover>
573-
{showAttachmentCamera && (
574-
<AttachmentCamera
575-
isVisible={showAttachmentCamera}
576-
onCapture={handleCameraCapture}
577-
onClose={handleCameraClose}
578-
/>
579-
)}
580531
{renderChildren()}
581532
</>
582533
);

0 commit comments

Comments
 (0)