[No QA] [TS migration] Migrate 'cropOrRotateImage' lib to TypeScript#27419
Conversation
| /** | ||
| * Crops and rotates the image on ios/android | ||
| */ | ||
| const cropOrRotateImage: CropOrRotateImage = (uri, actions, options) => |
There was a problem hiding this comment.
This seems a little weird to me. Any reason not to declare the types inline?
function cropOrRotateImage(uri: string, actions: Action[], options: CropOrRotateImageOptions): Promise<FileWithUri | RNManipulator > {
...
}There was a problem hiding this comment.
@thiagobrez when we have platform specific files we need to follow this pattern. Thats why its like that
| const file = new File([blob], options.name || 'fileName.jpeg', {type: options.type || 'image/jpeg'}); | ||
| file.uri = URL.createObjectURL(file); | ||
| resolve(file); | ||
| const fileWithUri = Object.assign(file, {uri: URL.createObjectURL(file)}); | ||
|
|
||
| resolve(fileWithUri); |
There was a problem hiding this comment.
const file = new File([blob], options.name || 'fileName.jpeg', {type: options.type || 'image/jpeg'}) as FileWithUri;
file.uri = URL.createObjectURL(file);
resolve(file);In this way you don't need to use Object.assign
| uri: string; | ||
| }; | ||
|
|
||
| type RNManipulator = RNImageManipulatorResult & {size: number; type: string; name: string}; |
There was a problem hiding this comment.
| type RNManipulator = RNImageManipulatorResult & {size: number; type: string; name: string}; | |
| type CustomRNImageManipulatorResult = RNImageManipulatorResult & {size: number; type: string; name: string}; |
| const file = Object.assign(result, {size, type: options.type || 'image/jpeg', name: options.name || 'fileName.jpg'}); | ||
| resolve(file); |
There was a problem hiding this comment.
| const file = Object.assign(result, {size, type: options.type || 'image/jpeg', name: options.name || 'fileName.jpg'}); | |
| resolve(file); | |
| resolve({ | |
| ...result, | |
| size, | |
| type: options.type || 'image/jpeg', | |
| name: options.name || 'fileName.jpg', | |
| }); |
The old way still works, isn't?
|
@srikarparsi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosWebclipFlipRecording.movMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/srikarparsi in version: 1.3.72-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.72-11 🚀
|
Details
Fixed Issues
$ 24839
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
web.mp4
Mobile Web - Chrome
Mobile Web - Safari
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4