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: App crashes while opening when the device is offline #481

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

PruthiviRaj27
Copy link
Contributor

@PruthiviRaj27 PruthiviRaj27 commented Jan 25, 2023

Issue

  • Fetching DB should not be done in the main thread. (ref - link)
  • In getAllProductCategories() we are fetching DB in the main thread which leads to an app crash.
  • This happens only when the device is offline. If the device is online we call this getAllProductCategories() inside the CoroutineScope

Solution

  • Calling this getAllProductCategories() in the background thread using (Dispatchers.IO) will fix this issue

Copy link
Contributor

@waranlogesh waranlogesh left a comment

Choose a reason for hiding this comment

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

Add the context on why loading the categories in main thread is crashing the app. Then only I can know whether this is a fix in the right place or now while reviewing.

@PruthiviRaj27 PruthiviRaj27 changed the title fix: App crash while opening when the internet is off fix: App crashes while opening when the device is offline Jan 30, 2023
@Karthik-0 Karthik-0 merged commit 0407911 into master Jan 31, 2023
@delete-merged-branch delete-merged-branch bot deleted the fixProductCategory branch January 31, 2023 06:32
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