-
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
[NoQA] feat: Remove moment from the project (Except Datepicker) #28175
[NoQA] feat: Remove moment from the project (Except Datepicker) #28175
Conversation
@situchan I wanted to split it to another(last PR), because datepicker has a loot of moment, but I can add it here if you wish |
@waterim oh ok, so eventually we completely deprecate moment from the project, right? |
@situchan Yes, Im finishing this transition with removing it fully, hopefully next week will be the last week(Im waiting for a bunch of regressions here) |
@allroundexperts 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] |
@allroundexperts Hey, do you have some updates here? |
@waterim Still testing. Can you please resolve conflicts? |
Damn, new changes are here, will resolve |
@allroundexperts resolved everything |
@@ -110,7 +110,7 @@ Onyx.connect({ | |||
* @param {String} id | |||
*/ | |||
function resetMoneyRequestInfo(id = '') { | |||
const created = currentDate || moment().format('YYYY-MM-DD'); | |||
const created = currentDate || format(new Date(), CONST.DATE.FNS_FORMAT_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.
This is yyyy-MM-dd
unlike YYYY-MM-DD
as it was previously.
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.
Yes, its the same, moment uses own formats, date-fns uses IANA and doesnt support YYYY-MM-DD
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.
Not sure about this comment, the output of the date here is same as from moment, right? @allroundexperts @waterim
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.
confirmed its the same in DM
src/libs/actions/MapboxToken.js
Outdated
@@ -42,7 +42,7 @@ const setExpirationTimer = () => { | |||
}, REFRESH_INTERVAL); | |||
}; | |||
|
|||
const hasTokenExpired = () => moment().isAfter(currentToken.expiration); | |||
const hasTokenExpired = () => isAfter(new Date(), currentToken.expiration); |
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 think this is incorrect. This should be isAfter(currentToken.expiration, new Date())
instead.
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, have you tested the format of currentToken.expiration
? It might be a string which will cause this to return false always.
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 think this is incorrect. This should be isAfter(currentToken.expiration, new Date()) instead."
Actually no, this is correct:
We use the isAfter function to compare the current date (new Date()) with currentToken.expiration.
The isTokenExpired variable will be true if the current date is after the expiration date, and false otherwise.
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 you post a screenshot of two dates using moment and isAfter 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.
sure, one moment
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.
new Date()
new Date(currentToken.expiration)
@allroundexperts
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'm talking about the input values themselves that you used for comparison.
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.
Get it, will show now
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.
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.
looks correct
@@ -460,7 +460,7 @@ function isBlockedFromConcierge(blockedFromConciergeNVP) { | |||
return false; | |||
} | |||
|
|||
return moment().isBefore(moment(blockedFromConciergeNVP.expiresAt), 'day'); | |||
return isBefore(new Date(), new Date(blockedFromConciergeNVP.expiresAt)); |
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 think this is incorrect again. It should be isBefore(new Date(blockedFromConciergeNVP.expiresAt), new Date())
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.
Here is correct again:
If new Date() is before new Date(blockedFromConciergeNVP.expiresAt) - it will be true
const year = yearMonth.substring(0, 4) || getYear(new Date()); | ||
const month = yearMonth.substring(4) || getMonth(new Date()); | ||
const monthName = format(new Date(year, month), CONST.DATE.MONTH_FORMAT); |
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.
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.
Probably new one is correct, I tried with new dates and moment is showing september for some reason, but date-fns October(which is correct)
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.
Working well. We just need to sort out the usage of isBefore
and isAfter
.
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-10-05.at.12.28.53.AM.movMobile Web - ChromeScreen.Recording.2023-10-05.at.12.35.25.AM.movMobile Web - SafariScreen.Recording.2023-10-05.at.12.34.07.AM.movDesktopScreen.Recording.2023-10-05.at.12.32.23.AM.moviOSScreen.Recording.2023-10-05.at.12.34.39.AM.movAndroidScreen.Recording.2023-10-05.at.12.36.29.AM.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.
Looks good!
@mountiny Should it be merged? |
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.
Thank you!
@@ -110,7 +110,7 @@ Onyx.connect({ | |||
* @param {String} id | |||
*/ | |||
function resetMoneyRequestInfo(id = '') { | |||
const created = currentDate || moment().format('YYYY-MM-DD'); | |||
const created = currentDate || format(new Date(), CONST.DATE.FNS_FORMAT_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.
confirmed its the same in DM
✋ 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/mountiny in version: 1.3.80-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.80-3 🚀
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.81-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
2 similar comments
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀
|
Details
This PR is for removing all moment and changing it with date-fns (Except Datepicker)
Fixed Issues
$ #19810
PROPOSAL: #19810 (comment)
Tests
N/A
Offline tests
Same as tests
QA Steps
None
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.