-
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
fix older safari launch app issue #33238
fix older safari launch app issue #33238
Conversation
@Santhosh-Sellavel 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] |
@@ -105,8 +105,8 @@ function getDefaultAvatar(accountID = -1, avatarURL?: string): React.FC<SvgProps | |||
// But the avatar link still corresponds to the original ID-generated link. So we extract the SVG image number from the backend's link instead of using the user ID directly | |||
let accountIDHashBucket: AvatarRange; | |||
if (avatarURL) { | |||
const match = avatarURL.match(/(?<=default-avatar_)\d+(?=\.)/); | |||
const lastDigit = match && parseInt(match[0], 10); | |||
const match = avatarURL.match(/(default-avatar_)(\d+)(?=\.)/); |
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.
can we add unit test? I think this can be easily broken in the future
btw, not blocker
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.
Good point, I agree. Would you mind doing that @rojiphil?
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.
Sure. Let me check.
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.
Added unit test
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Desktopdesktop.mov |
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.
Tests well!
@Julesssss #32090 was deployed to staging and app doesn't load on safari. |
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.
Code is looking good, but I agree it would be great to add a unit test to avoid regressions.
@Julesssss @situchan |
it('should return the default avatar from the avatar url', () => { | ||
const avatarURL = 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_7.png'; | ||
const defaultAvatar = UserUtils.getDefaultAvatar(1, avatarURL); | ||
expect(typeof defaultAvatar).toBe('function'); |
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 useless. I was expecting accountIDHashBucket
to be returned. Also add some more cases including invalid ones.
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 useless. I was expecting
accountIDHashBucket
to be returned.
@situchan
Not sure if I understood your expectation correctly here as the function getDefaultAvatar
does not return accountIDHashBucket
.
Can you please explain more about your expectation? Maybe, pointing to an existing unit test case of a similar kind can also help. Maybe I am missing something simple here.
Also add some more cases including invalid ones.
When the regex fails, the function will return undefined
. I can add a case for the invalid one.
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 was thinking the purpose of this test was to evaluate regex.
But you reused this function (getDefaultAvatar) which doesn't detect regex is right or not.
If no other way, better to remove this redundant test
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.
Also, since our issue here was due to lack of lookbehind
support in older safari versions, I am wondering how a unit test case will detect this.
I am not sure if the test cases are run against specific versions of browser.
I would like to know your thoughts on this.
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.
Similar concern: #25742 (comment)
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.
Maybe create lint rule something like https://eslint.org/docs/latest/rules/no-useless-backreference but out of scope for this PR.
I am fine to merge as is for now.
cc: @Julesssss
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.
Maybe create lint rule something like https://eslint.org/docs/latest/rules/no-useless-backreference but out of scope for this PR.
I think this is an interesting approach and worth considering.
But yes, I also think this is out of scope for this PR.
The checklist has changed. I'm skipping this |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@rojiphil @Julesssss our QA team does not have Mac Safari 16.3 version. Could you validate this internally? |
@kavimuru 33215-issue-verification.mp4 |
@rojiphil can I check it off the list? One of our tester has 15.x version. Can we validate with 15.x Safari version? |
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.16-5 🚀
|
@situchan @alitoshmatov @Julesssss
Details
This PR uses capture groups instead of lookbehind to support older safari versions (v 16.3) for avatar URL so that the app can launch successfully.
Declaration: I could not test on Android Native due to the pending issue as per slack thread here.
Since this issue has to do with web/mWeb Safari platform, this may not be an issue here.
Fixed Issues
$ #33215
PROPOSAL: #33215 (comment)
Tests
Steps
Precondition: Safari version: 16.3
Expected Result: The App should load correctly and the avatars should be displayed.
Offline tests
Same as the Steps for Tests Section.
QA Steps
Same as the Steps for Tests Section.
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
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 - Safari
33215-web-safari-2.mp4
Mobile Web - Safari
33215-mweb-safari.mp4
Desktop
33215-desktop.mp4
iOS
33215-ios-native.mp4
Android
Not done due to the pending issue as per slack thread here.
Plus since this issue has to do with web/mWeb Safari platform, this may not be a matter of concern here.
Mobile Web - Chrome
33215-mweb-chrome.mp4