Skip to content

Commit

Permalink
fix: more linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispader committed Feb 7, 2025
1 parent 46a5ec6 commit 9ac0f70
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 41 deletions.
41 changes: 23 additions & 18 deletions src/components/AttachmentPicker/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Str} from 'expensify-common';
import {manipulateAsync, SaveFormat} from 'expo-image-manipulator';
import {ImageManipulator, SaveFormat} from 'expo-image-manipulator';
import React, {useCallback, useMemo, useRef, useState} from 'react';
import {Alert, View} from 'react-native';
import RNFetchBlob from 'react-native-blob-util';
Expand Down Expand Up @@ -178,23 +178,28 @@ function AttachmentPicker({
.then((isHEIC) => {
// react-native-image-picker incorrectly changes file extension without transcoding the HEIC file, so we are doing it manually if we detect HEIC signature
if (isHEIC && targetAssetUri) {
manipulateAsync(targetAssetUri, [], {format: SaveFormat.JPEG})
.then((manipResult) => {
const uri = manipResult.uri;
const convertedAsset = {
uri,
name: uri
.substring(uri.lastIndexOf('/') + 1)
.split('?')
.at(0),
type: 'image/jpeg',
width: manipResult.width,
height: manipResult.height,
};

return resolve([convertedAsset]);
})
.catch((err) => reject(err));
ImageManipulator.manipulate(targetAssetUri)
.renderAsync()
.then((image) =>
image
.saveAsync({format: SaveFormat.JPEG})
.then((manipResult) => {
const uri = manipResult.uri;
const convertedAsset = {
uri,
name: uri
.substring(uri.lastIndexOf('/') + 1)
.split('?')
.at(0),
type: 'image/jpeg',
width: manipResult.width,
height: manipResult.height,
};

return resolve([convertedAsset]);
})
.catch((err) => reject(err)),
);
} else {
return resolve(response.assets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function VideoRenderer({tnode, key}: VideoRendererProps) {
<VideoPlayerPreview
key={key}
videoUrl={sourceURL}
reportID={currentReportIDValue?.currentReportID ?? '-1'}
reportID={currentReportIDValue?.currentReportID}
fileName={fileName}
thumbnailUrl={thumbnailUrl}
videoDimensions={{width, height}}
Expand All @@ -46,7 +46,7 @@ function VideoRenderer({tnode, key}: VideoRendererProps) {
if (!sourceURL || !type) {
return;
}
const route = ROUTES.ATTACHMENTS.getRoute({reportID: report?.reportID ?? '-1', type, source: sourceURL, accountID});
const route = ROUTES.ATTACHMENTS.getRoute({reportID: report?.reportID, type, source: sourceURL, accountID});
Navigation.navigate(route);
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/VideoPlayerPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type VideoPlayerPreviewProps = {
videoUrl: string;

/** reportID of the video */
reportID: string;
reportID: string | undefined;

/** Dimension of a video. */
videoDimensions: VideoDimensions;
Expand Down
3 changes: 1 addition & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ import CONFIG from '@src/CONFIG';
import type {OnboardingAccounting, OnboardingCompanySize} from '@src/CONST';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import ROUTES from '@src/ROUTES';
import INPUT_IDS from '@src/types/form/NewRoomForm';
import type {
Expand Down Expand Up @@ -2960,7 +2959,7 @@ function openReportFromDeepLink(url: string) {
return;
}

Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
Navigation.navigate(route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
};

if (isAnonymousUser()) {
Expand Down
20 changes: 12 additions & 8 deletions src/libs/fileDownload/getImageManipulator/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import {manipulateAsync} from 'expo-image-manipulator';
import {ImageManipulator} from 'expo-image-manipulator';
import type {FileObject} from '@pages/media/AttachmentModalScreen/types';
import type ImageManipulatorConfig from './type';

export default function getImageManipulator({fileUri, width, height, type, fileName}: ImageManipulatorConfig): Promise<FileObject> {
return manipulateAsync(fileUri ?? '', [{resize: {width, height}}]).then((result) => ({
uri: result.uri,
width: result.width,
height: result.height,
type,
name: fileName,
}));
return ImageManipulator.manipulate(fileUri ?? '')
.resize({width, height})
.renderAsync()
.then((image) => image.saveAsync())
.then((result) => ({
uri: result.uri,
width: result.width,
height: result.height,
type,
name: fileName,
}));
}
24 changes: 14 additions & 10 deletions src/libs/fileDownload/getImageManipulator/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import {manipulateAsync} from 'expo-image-manipulator';
import {ImageManipulator} from 'expo-image-manipulator';
import type ImageManipulatorConfig from './type';

export default function getImageManipulator({fileUri, width, height, fileName}: ImageManipulatorConfig): Promise<File> {
return manipulateAsync(fileUri ?? '', [{resize: {width, height}}]).then((result) =>
fetch(result.uri)
.then((res) => res.blob())
.then((blob) => {
const resizedFile = new File([blob], `${fileName}.jpeg`, {type: 'image/jpeg'});
resizedFile.uri = URL.createObjectURL(resizedFile);
return resizedFile;
}),
);
return ImageManipulator.manipulate(fileUri ?? '')
.resize({width, height})
.renderAsync()
.then((image) => image.saveAsync())
.then((result) =>
fetch(result.uri)
.then((res) => res.blob())
.then((blob) => {
const resizedFile = new File([blob], `${fileName}.jpeg`, {type: 'image/jpeg'});
resizedFile.uri = URL.createObjectURL(resizedFile);
return resizedFile;
}),
);
}

0 comments on commit 9ac0f70

Please sign in to comment.