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: crash when restoring the app after a long period of inactivity #290

Merged
merged 1 commit into from
May 15, 2024

Conversation

dixidroid
Copy link
Contributor

@dixidroid dixidroid commented Apr 15, 2024

Changed the way course data is loaded.

Previously there was the preloadCourseStructure function that was called when we opened a course. Then all data was cached and used in other places such as open content and etc. When the app was in the background for a long time all the data was cleared by the system and if the user tries to open the app - it crashes.

I changed the way the Course Structure is retrieved and added a check for empty data.

#139

@omerhabib26
Copy link
Contributor

Reviewing

@HamzaIsrar12
Copy link
Contributor

Hey @dixidroid, just a heads-up, this PR will remain in a stale position until we merge #278, as it will update the underlying code fixed in this PR. 🕐

@HamzaIsrar12
Copy link
Contributor

@dixidroid The base PR has been merged. Could you please reassess the scope of this ticket? Thank You

@dixidroid dixidroid force-pushed the fix/crash_when_restore branch 2 times, most recently from 787ba1c to fabe057 Compare May 7, 2024 11:11
@dixidroid
Copy link
Contributor Author

@HamzaIsrar12 we still need this PR. All conflicts were resolved.

courseId
)
courseDao.insertCourseStructureEntity(response.mapToRoomEntity())
courseStructure[courseId] = response.mapToDomain()

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 243 to 246
fun updateData() {
viewModelScope.launch {
try {
interactor.preloadCourseStructure(courseId)
interactor.getCourseStructure(courseId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it actually update the data, or will it just return the last cached course?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, but I changed how it works and right now it should update the data )

@volodymyr-chekyrta
Copy link
Contributor

The overall approach looks good.
Concern that the updateData function just returns cached data instead of reloading.

@omerhabib26
Copy link
Contributor

Resuming the review

omerhabib26
omerhabib26 previously approved these changes May 9, 2024
Copy link
Contributor

@omerhabib26 omerhabib26 left a comment

Choose a reason for hiding this comment

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

LGTM

@volodymyr-chekyrta volodymyr-chekyrta merged commit ae777dd into openedx:develop May 15, 2024
3 checks passed
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.

4 participants