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

Remove Promise#finally from course search #2643

Merged
merged 4 commits into from
Jun 10, 2018

Conversation

hawkrives
Copy link
Member

Closes #2502

There are two changes in here.


	componentDidMount() {
-		areAnyTermsCached().then(anyTermsCached => {
-			if (anyTermsCached) {
-				this.loadData()
-			} else {
-				this.setState(() => ({dataLoading: false}))
-			}
-		})
+		this.loadData()

This one … so far as I can tell, the check here is duplicated in loadData, both in the if (this.props.courseDataState !== 'ready') check and the if (await areAnyTermsCached()).

That is to say, we need to call loadData if the courses haven't been loaded into RAM (courseDataState !== 'ready'), and … well, TBH I can't quite tell why the areAnyTermsCached was there in componentDidMount.


The other change is to remove the .finally(() => this.doneLoading()) line from loadData. I did this by converting it from a promise chain to an async function. My translation should be equivalent here, esp. the this.setState(() => ({dataLoading: false})) bit right after the if-else blocks.

@hawkrives hawkrives requested review from rye and hannesmcman June 10, 2018 03:27
@drewvolz drewvolz merged commit 24d7e8d into master Jun 10, 2018
@rye rye deleted the course-search-promise-finally branch June 16, 2018 03:38
@rye rye added this to the v2.6 milestone Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants