-
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 switching Priority Mode with an active draft message from crashing app #7907
Conversation
Actually, filter is not the solution. We use map because we need to replace old report object with new 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.
Changes look good, but I did have a question or two. I found this file really hard to follow and think it could be improved, but no expectations to do that in this PR. 😄
unreadReports: SidebarLinks.getUnreadReports(props.reports || {}), | ||
}; | ||
} | ||
|
||
static getDerivedStateFromProps(nextProps, prevState) { | ||
const shouldReorder = SidebarLinks.shouldReorder(nextProps, prevState.orderedReports, prevState.currentlyViewedReportID, prevState.unreadReports); | ||
const switchingPriorityModes = nextProps.priorityMode !== prevState.priorityMode; |
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 compare this.props.priorityMode
with nextProps.priorityMode
and leave state
out of the equation entirely?
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.props isn't available within getDerivedStateFromProps
for some reason.
Out of curiosity, why do you want to leave state out of the equation? Bc we are not using state.priorityMode
anywhere else?
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.
Bc we are not using state.priorityMode anywhere else
That, and we're just setting whatever is in props directly to state which usually means it does not need to be there. If we need to track the updates of a prop then we can just look at the prop.
Anyway, I think we are basically stuck at this point and would need to refactor the entire component to fix this. I'm remembering now that this is a static method and can't access the component instance at all.
There are some good explanations here that go into why we should not use this here (but hopefully the explanation I just gave also makes sense).
https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html
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 would actually be super interested in refactoring the entire component
However, should I scale back some of the changes then to get somethign merged now? Right now the undefineds are causing a crash, or requires a hard refresh
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! I created this issue here - feel free to steal it from me.
But agree we should just fix this for now :D
Updated. I tested it on all platforms, videos of the tests above. Definitely encouraged to test though! Added a lot of regression testing as well |
@pecanoro friendly bump! |
✋ 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 production by @chiragsalian in version: 1.1.42-6 🚀
|
@Expensify/pullerbear
cc @marcaaron
Details
This was a tricky bug to find. I'm mostly worried about regression so ideally we can really test this thoroughly
Fixed Issues
$ #7810
$ #7811
Tests / QA Steps
Fix tests
Regression
Part of the bug was introduced in this PR (#6084), so lets take their tests word for word and test them
PR Review Checklist
Contributor (PR Author) Checklist
main
before submitting my PR for review### Fixed Issues
section abovesrc/languages/*
files (if applicable)Styling.md
) for all style edits I madePR Reviewer Checklist
main
before submitting the PR### Fixed Issues
section abovesrc/languages/*
files (if applicable)Tested On
Screenshots
Web
Above
Desktop
https://recordit.co/hU5T21bVYm
iOS
https://recordit.co/sE7YS8nxIo
Android
https://recordit.co/2Tt6hj5jw2