-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[No QA] [TS migration] Migrate 'cropOrRotateImage' lib to TypeScript #27419
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thiagobrez when we have platform specific files we need to follow this pattern. Thats why its like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kubabutkiewicz Cool! 👍🏻
src/libs/cropOrRotateImage/index.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed @fabioh8010
src/libs/cropOrRotateImage/types.ts
Outdated
uri: string; | ||
}; | ||
|
||
type RNManipulator = RNImageManipulatorResult & {size: number; type: string; name: string}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type RNManipulator = RNImageManipulatorResult & {size: number; type: string; name: string}; | |
type CustomRNImageManipulatorResult = RNImageManipulatorResult & {size: number; type: string; name: string}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed @fabioh8010
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fixed @fabioh8010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kubabutkiewicz LGTM
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
✋ 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.mp4
Mobile Web - Chrome
Mobile Web - Safari
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4