🧼 Techdebt/sync reduce rate fpf#228
Merged
Merged
Conversation
Added a remote config to modulate the sync and non sync durations update the core module
Contributor
📱 DescriptionThis PR refactors the currency rate synchronization mechanism to reduce the frequency of API polling during blockchain sync operations. It moves the polling logic from Platform
🎯 Type of Change
📋 ChangesNew Components Added
Modifications
Removals
📊 Statistics
🔗 Related Issues
🧪 Tests Status
📸 Screenshots/Videos
🎯 ReviewersDraft Status: This PR is currently in draft mode and ready for review feedback.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📱 Description
This PR refactors the currency rate synchronization mechanism to reduce the frequency of API polling during blockchain sync operations. It moves the polling logic from
CurrencyUpdateWorkerintoLtcRepositoryImpl, introduces remote config-driven delay intervals based on sync progress, and switches fromStateFlowtoSharedFlowfor rates distribution. Additionally, it removes the Bitrefill affiliate link and updates WebView configuration.Platform
🎯 Type of Change
📋 Changes
New Components Added
RemoteConfigSource.kt– Added constants for sync poller, shop content, API base URLs, and feature flags to enable server-side configuration control.SyncPoolerContentWrapperdata class inLtcRepositoryImpl.kt– Serializable model for parsing remote config JSON containing sync and non-sync delay values.LtcRepositoryImpl.kt– Implements a continuous polling loop that fetches rates at intervals determined by blockchain sync progress and remote config, replacing the separate worker pattern.Modifications
LtcRepository.kt– Changedratesproperty fromStateFlow<List<CurrencyEntity>>toSharedFlow<List<CurrencyEntity>>to support multicast without state retention semantics.LtcRepositoryImpl.kt– Migrated polling logic fromCurrencyUpdateWorkerinto repository init block; addedremoteConfigSourceandpeerManagerSourcedependencies; implemented adaptive delay based onblockInfo.syncProgress; seededMutableSharedFlowwith cached currencies on creation.LTCPickerBentoViewModel.kt– Removed manual polling loop (5s interval); replaced with reactive collection ofltcRepository.ratesSharedFlow; removedfetchAndUpdateRates()method call on currency change (now automatic via flow).BRActivity.java– RemovedCurrencyUpdateWorker.start()call and related imports; polling now managed by repository initialization.MainScreen.kt– AddedfillMaxSize()modifier toWebModalScreenfor Bitrefill web view.WebModalScreen.kt– Enhanced AndroidView setup: added explicit layout params, background color, JavaScript/DOM storage settings; converted to useupdateblock for URL loading; improved WebViewClient with lifecycle callbacks.BWConstants.kt– Removed affiliate parameter fromBITREFILL_URL(changed fromhttps://www.bitrefill.com/?ref=bAshL935tohttps://www.bitrefill.com/).remote_config_defaults.xml– Added 10 new remote config entries including sync poller delays (60s sync, 4s non-sync), shop content URL, API base URLs, and feature toggles; reformatted XML indentation.Removals
CurrencyUpdateWorker.kt– Deleted; polling responsibility moved intoLtcRepositoryImplinitialization to reduce architectural complexity and enable remote config control.📊 Statistics
🎯 Reviewers
@kcw-grunt, @josikie
sync_delay,non_sync_delaykeys); validate Firebase Remote Config default matches.blockInfo.syncProgress <= 0.95f; confirm this threshold aligns with product requirements.LocalContext.currentreference and improved configuration; test cross-platform WebView behavior on different Android versions.timber|| rates in fetching,timber|| duration in fetching)—remove or adjust log level for production.