Skip to content
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(archive): Fix blank screen when sorting #1153

Merged
merged 4 commits into from
Jan 17, 2020

Conversation

mickr
Copy link
Contributor

@mickr mickr commented Jan 16, 2020

  • Add try/catch handler for exceptions
  • Handle case when sorting data is falsy

* Add try/catch handler for exceptions
* Handle case when sorting data is falsy
@mickr mickr requested a review from a team as a code owner January 16, 2020 22:09
@boxcla
Copy link

boxcla commented Jan 16, 2020

Verified that @mickr has signed the CLA. Thanks for the pull request!

src/lib/viewers/archive/ArchiveExplorer.js Outdated Show resolved Hide resolved
if (typeof a[sortBy] === 'number' && typeof b[sortBy] === 'number') {
return a[sortBy] - b[sortBy];
}
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we should be able to guard against pretty much any issues without resorting to try/catch here. I think we should add a componentDidCatch to the parent component, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are safe as well, but I through it in for good measure to ensure we always get an itemList returned.

Copy link
Collaborator

@jstoffan jstoffan Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, try/catch should be reserved for exception handling rather than for flow control. I don't think it hurts in this case, but it can get overused.

src/lib/viewers/archive/ArchiveExplorer.js Outdated Show resolved Hide resolved
jstoffan
jstoffan previously approved these changes Jan 16, 2020
Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add a test case with some bad data to validate these new code branches.

* Remove try/catch
* Add test for comparing to null values in the sort
@mickr
Copy link
Contributor Author

mickr commented Jan 17, 2020

I will follow this up with a componentDidCatch in the React tree to catch exceptions in the future.

@mergify mergify bot merged commit 5c6cc96 into box:master Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants