Skip to content

Commit

Permalink
migrate to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
eucool committed Mar 10, 2024
1 parent 778f35d commit 8ccd9cc
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/libs/fileDownload/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type GetImageResolution = (url: File | Asset) => Promise<ImageResolution>;
type ExtensionAndFileName = {fileName: string; fileExtension: string};
type SplitExtensionFromFileName = (fileName: string) => ExtensionAndFileName;

type ReadFileAsync = (path: string, fileName: string, onSuccess: (file: File) => void, onFailure: (error?: unknown) => void, fileType?: string) => Promise<File | void>;
type ReadFileAsync = (path: string, fileName: string, onSuccess: (file: File) => void, onFailure?: (error?: unknown) => void, fileType?: string) => Promise<File | void>;

type AttachmentDetails = {
previewSourceURL: null | string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type CameraPermissionModule from './types';


const CameraPermission: CameraPermissionModule = {
requestCameraPermission: undefined,
getCameraPermissionStatus: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function NavigationAwareCamera({torchOn, onTorchAvailability, cameraTabIndex, ..
}

trackRef.current.applyConstraints({
// @ts-expect-error there is a type mismatch in typescipt types for MediaStreamTrack https://github.com/microsoft/TypeScript/issues/39010
advanced: [{torch: torchOn}],
});
}, [torchOn]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ function IOURequestStepScan({
// Store the receipt on the transaction object in Onyx
// On Android devices, fetching blob for a file with name containing spaces fails to retrieve the type of file.
// So, let us also save the file type in receipt for later use during blob fetch
IOU.setMoneyRequestReceipt(transactionID, file.uri, file.name, action !== CONST.IOU.ACTION.EDIT, file.type);
IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name, action !== CONST.IOU.ACTION.EDIT, file.type);

if (action === CONST.IOU.ACTION.EDIT) {
updateScanAndNavigate(file, file.uri);
updateScanAndNavigate(file, file?.uri ?? '');
return;
}

Expand All @@ -208,7 +208,6 @@ function IOURequestStepScan({
const capturePhoto = useCallback(() => {
if (!camera.current && (cameraPermissionStatus === RESULTS.DENIED || cameraPermissionStatus === RESULTS.BLOCKED)) {
askForPermissions(cameraPermissionStatus !== RESULTS.DENIED);
return;
}

const showCameraAlert = () => {
Expand All @@ -217,11 +216,9 @@ function IOURequestStepScan({

if (!camera.current) {
showCameraAlert();
return;
}

return camera.current
.takePhoto({
camera?.current?.takePhoto({
qualityPrioritization: 'speed',
flash: flash ? 'on' : 'off',
})
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function IOURequestStepScan({
src={Hand}
width={CONST.RECEIPT.HAND_ICON_WIDTH}
height={CONST.RECEIPT.HAND_ICON_HEIGHT}
style={[styles.pb5]}
additionalStyles={[styles.pb5]}
/>
<Text style={[styles.textReceiptUpload]}>{translate('receipt.takePhoto')}</Text>
<Text style={[styles.subTextReceiptUpload]}>{translate('receipt.cameraAccess')}</Text>
Expand Down

0 comments on commit 8ccd9cc

Please sign in to comment.