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

Make activateSurvey call blocking #3021

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shobhitagarwal1612
Copy link
Member

@shobhitagarwal1612 shobhitagarwal1612 commented Jan 22, 2025

Fixes #3020

This PR aims to make the behavior of activate survey deterministic by making the call wait until the survey has been activated i.e. the survey gets fetched from local db and is emitted by the flow.

Without this, today the UI assumes that the survey has been activated and the screens are ready to consume it. This may lead to unwanted behavior if the next screen expects the value to be available immediately.

The function waits for 3s before throwing an error. Instead of crashing the app, we display an error toast that "something went wrong" and the user can try again.

@gino-m @sufyanAbbasi @anandwana001 PTAL?

@auto-assign auto-assign bot requested a review from anandwana001 January 22, 2025 18:12
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 63.60%. Comparing base (a0975c3) to head (1f01f8b).

Files with missing lines Patch % Lines
...round/ui/surveyselector/SurveySelectorViewModel.kt 76.92% 2 Missing and 1 partial ⚠️
...ogle/android/ground/repository/SurveyRepository.kt 75.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3021      +/-   ##
============================================
+ Coverage     63.55%   63.60%   +0.05%     
- Complexity     1267     1270       +3     
============================================
  Files           270      270              
  Lines          6560     6572      +12     
  Branches        927      930       +3     
============================================
+ Hits           4169     4180      +11     
- Misses         1786     1788       +2     
+ Partials        605      604       -1     
Files with missing lines Coverage Δ
...in/java/com/google/android/ground/MainViewModel.kt 82.35% <100.00%> (+3.62%) ⬆️
...nd/domain/usecases/survey/ActivateSurveyUseCase.kt 100.00% <100.00%> (ø)
...ain/usecases/survey/ReactivateLastSurveyUseCase.kt 100.00% <ø> (ø)
...ogle/android/ground/repository/SurveyRepository.kt 85.71% <75.00%> (+8.29%) ⬆️
...round/ui/surveyselector/SurveySelectorViewModel.kt 86.53% <76.92%> (-7.08%) ⬇️

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.

Use activeSurvey instead of selectedSurveyId as it is possible to have no active survey....
1 participant