-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 LinkPreviewer component to TypeScript #32822
[NO QA] [TS migration] Migrate LinkPreviewer component to TypeScript #32822
Conversation
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!
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const StyleUtils = useStyleUtils(); | ||
const uniqueLinks = linkMetadata.filter((link, index, self) => self.findIndex((t) => t.url === link.url) === index); |
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.
minor but maybe you can change t
variable name to something more meaningful?
@SzymczakJ please resolve conflicts and I think you should remove |
@shubham1206agra 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] |
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const StyleUtils = useStyleUtils(); | ||
const uniqueLinks = linkMetadata.filter((link, index) => linkMetadata.findIndex(({url}) => url === link.url) === index); |
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 is a slower implementation of uniqBy function.
Maybe use this
const uniqBy = (arr: any[], predicate: (item: any) => string) => {
const cb = typeof predicate === 'function' ? predicate : (o) => o[predicate];
const result = [];
const map = new Map();
arr.forEach((item) => {
const key = (item === null || item === undefined) ? item : cb(item);
if (!map.has(key)) {
map.set(key, item);
result.push(item);
}
});
return result;
};
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.
Indeed this is a better and faster implementation. But do we need something like this? linkMetadata is in 99.9% of times, a really small array(1 - 3 elements) and this optimization is not giving us that much(also _.uniqBy function is used only once in our codebase, so we won't be able to reuse it). That being said, can we keep the current implementation, as it seems to me that it's a little easier to understand?
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.
I agree that most of the cases won't have problem with the current implementation. But lets keep the optimised implementation as current implementation may introduce extra latencies, which we don't want
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.
changed filter to better implementation. How do you like it?
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.
@shubham1206agra seems like you forgot to press approve 😅
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.
Oh I just need to test this once. I will approve this today.
Can you merge main here? |
@shubham1206agra merged main |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeScreen.Recording.2023-12-20.at.7.58.42.PM.moviOS: mWeb SafariScreen.Recording.2023-12-20.at.7.38.53.PM.movMacOS: Chrome / SafariScreen.Recording.2023-12-20.at.7.36.31.PM.movMacOS: DesktopScreen.Recording.2023-12-20.at.7.50.06.PM.mov |
We did not find an internal engineer to review this PR, trying to assign a random engineer to #31948 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
@bondydaa Looks like this PR needs your approval |
✋ 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/bondydaa in version: 1.4.15-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.4.15-5 🚀
|
Details
Migration of 'LinkPreviewer' to Typescript. This cannot be tested by QA because link preview permission is globally set to false. If you want to test it, set Permissions.canUseLinkPreview() to return True and send links in chat.
Fixed Issues
$ #31948
PROPOSAL: N/A
Tests
Offline tests
N/A
QA Steps
N/A This issue cannot be currently tested without hacking the Permissions in app. At this moment link previews permission is set to false. I've set this to true in code and made sure the LinkPreview works as expected, but someone that cannot change the codebase won't be able to test this.
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)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
Android: Native
android.mov
Android: mWeb Chrome
androidweb.mov
iOS: Native
ios.mov
iOS: mWeb Safari
iosweb.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov