Skip to content

Improve force update to also suspend firebase requests - #3936

Open
andreia-ferreira wants to merge 8 commits into
masterfrom
andreia/force-update-blocks-api-calls
Open

andreia-ferreira wants to merge 8 commits into
masterfrom
andreia/force-update-blocks-api-calls

Conversation

@andreia-ferreira

Copy link
Copy Markdown
Collaborator

When a force update is enabled, the outdated apps still continue requests to firebase. This PR makes the requests also stop before the app is updated. All pending mutations stay queued locally and should upload after the update.

This could be useful in case a specific version ships with a bug that may flood firebase with requests or bad data (since work manager can keep making requests in the background regardless if the app is in use or not), so that all traffic can be shut off right away instead of waiting for all users to update.

In order to do this, the logic that fetched the remote config and verified if an update was needed was refactored to a repository and a usecase so it could be better reused.

@shobhitagarwal1612 PTAL?

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.21%. Comparing base (bf1fdfb) to head (3260492).

Files with missing lines Patch % Lines
...atform/domain/usecases/ShouldForceUpdateUseCase.kt 81.25% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3936      +/-   ##
============================================
+ Coverage     69.99%   70.21%   +0.22%     
- Complexity     2034     2055      +21     
============================================
  Files           424      427       +3     
  Lines         11648    11667      +19     
  Branches       1522     1521       -1     
============================================
+ Hits           8153     8192      +39     
+ Misses         2722     2701      -21     
- Partials        773      774       +1     
Files with missing lines Coverage Δ
...platform/android/data/remote/DataStoreException.kt 62.50% <100.00%> (+5.35%) ⬆️
...tform/android/data/sync/LocalMutationSyncWorker.kt 100.00% <100.00%> (ø)
...undplatform/android/data/sync/MediaUploadWorker.kt 86.11% <100.00%> (+0.81%) ⬆️
...oundplatform/android/data/sync/SurveySyncWorker.kt 100.00% <100.00%> (ø)
...platform/android/repository/AppConfigRepository.kt 100.00% <100.00%> (ø)
...org/groundplatform/android/ui/main/MainActivity.kt 56.81% <100.00%> (+12.50%) ⬆️
...rg/groundplatform/android/ui/main/MainViewModel.kt 83.67% <100.00%> (+16.46%) ⬆️
...otlin/org/groundplatform/domain/model/AppConfig.kt 100.00% <100.00%> (ø)
...atform/domain/usecases/ShouldForceUpdateUseCase.kt 81.25% <81.25%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}
}

class UpdateRequiredException : DataStoreException("App update required")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we rename to AppUpdateRequiredException?


@Provides
fun providesShouldForceUpdateUseCase(appConfigRepositoryInterface: AppConfigRepositoryInterface) =
org.groundplatform.domain.usecases.ShouldForceUpdateUseCase(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Can we import the use case instead of using fully qualified imports?

}
}
} catch (_: UpdateRequiredException) {
// Popup prompting the user to update is displayed, so we don't need to do anything here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of silently consuming the exception, can we instead create a new UiEvent which the ui layer can then listen to for showing the dialog?

Comment on lines +164 to 165
if (viewModel.isAppUpdateRequired()) {
showForceUpdateDialog()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please see the other comment.

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.

2 participants