Skip to content

🧼 Techdebt/sync reduce rate fpf#228

Merged
kcw-grunt merged 2 commits into
developfrom
techdebt/sync-reduce-rate-fpf
May 1, 2026
Merged

🧼 Techdebt/sync reduce rate fpf#228
kcw-grunt merged 2 commits into
developfrom
techdebt/sync-reduce-rate-fpf

Conversation

@kcw-grunt

@kcw-grunt kcw-grunt commented May 1, 2026

Copy link
Copy Markdown
Collaborator

📱 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 CurrencyUpdateWorker into LtcRepositoryImpl, introduces remote config-driven delay intervals based on sync progress, and switches from StateFlow to SharedFlow for rates distribution. Additionally, it removes the Bitrefill affiliate link and updates WebView configuration.

Platform

  • Android

🎯 Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Refactoring (code change that neither fixes a bug nor adds a feature)
  • 📚 Documentation update
  • 🎨 UI/UX improvement
  • ⚡ Performance improvement
  • 🧪 Test addition or improvement

📋 Changes

New Components Added

  • Remote config keys in RemoteConfigSource.kt – Added constants for sync poller, shop content, API base URLs, and feature flags to enable server-side configuration control.
  • SyncPoolerContentWrapper data class in LtcRepositoryImpl.kt – Serializable model for parsing remote config JSON containing sync and non-sync delay values.
  • Init block in 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 – Changed rates property from StateFlow<List<CurrencyEntity>> to SharedFlow<List<CurrencyEntity>> to support multicast without state retention semantics.
  • LtcRepositoryImpl.kt – Migrated polling logic from CurrencyUpdateWorker into repository init block; added remoteConfigSource and peerManagerSource dependencies; implemented adaptive delay based on blockInfo.syncProgress; seeded MutableSharedFlow with cached currencies on creation.
  • LTCPickerBentoViewModel.kt – Removed manual polling loop (5s interval); replaced with reactive collection of ltcRepository.rates SharedFlow; removed fetchAndUpdateRates() method call on currency change (now automatic via flow).
  • BRActivity.java – Removed CurrencyUpdateWorker.start() call and related imports; polling now managed by repository initialization.
  • MainScreen.kt – Added fillMaxSize() modifier to WebModalScreen for Bitrefill web view.
  • WebModalScreen.kt – Enhanced AndroidView setup: added explicit layout params, background color, JavaScript/DOM storage settings; converted to use update block for URL loading; improved WebViewClient with lifecycle callbacks.
  • BWConstants.kt – Removed affiliate parameter from BITREFILL_URL (changed from https://www.bitrefill.com/?ref=bAshL935 to https://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 into LtcRepositoryImpl initialization to reduce architectural complexity and enable remote config control.

📊 Statistics

  • Additions: 184 lines
  • Deletions: 104 lines
  • Files Changed: 11
  • Commits: 2

🎯 Reviewers

@kcw-grunt, @josikie


⚠️ Review Notes

  • Architecture: Polling moved from Worker pattern to repository initialization—ensure proper coroutine scope lifecycle and cancellation during app termination.
  • Remote Config: JSON parsing expects exact schema (sync_delay, non_sync_delay keys); validate Firebase Remote Config default matches.
  • SharedFlow vs StateFlow: Late collectors won't replay history. Verify UI components handle the first emission correctly.
  • Sync Progress Logic: Polling delays adapts based on blockInfo.syncProgress <= 0.95f; confirm this threshold aligns with product requirements.
  • WebView Changes: Removed LocalContext.current reference and improved configuration; test cross-platform WebView behavior on different Android versions.
  • Timber Logging: Added debug logging (timber|| rates in fetching, timber|| duration in fetching)—remove or adjust log level for production.

kcw-grunt added 2 commits May 1, 2026 23:21
Added a remote config to modulate the sync and non sync durations
update the core module
@kcw-grunt
kcw-grunt requested a review from josikie May 1, 2026 22:44
@kcw-grunt kcw-grunt self-assigned this May 1, 2026
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

🤖 Auto-generated by GitHub Copilot — edit as needed before merging.

📱 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 CurrencyUpdateWorker into LtcRepositoryImpl, introduces remote config-driven delay intervals based on sync progress, and switches from StateFlow to SharedFlow for rates distribution. Additionally, it removes the Bitrefill affiliate link and updates WebView configuration.

Platform

  • Android

🎯 Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Refactoring (code change that neither fixes a bug nor adds a feature)
  • 📚 Documentation update
  • 🎨 UI/UX improvement
  • ⚡ Performance improvement
  • 🧪 Test addition or improvement

📋 Changes

New Components Added

  • Remote config keys in RemoteConfigSource.kt – Added constants for sync poller, shop content, API base URLs, and feature flags to enable server-side configuration control.
  • SyncPoolerContentWrapper data class in LtcRepositoryImpl.kt – Serializable model for parsing remote config JSON containing sync and non-sync delay values.
  • Init block in 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 – Changed rates property from StateFlow<List<CurrencyEntity>> to SharedFlow<List<CurrencyEntity>> to support multicast without state retention semantics.
  • LtcRepositoryImpl.kt – Migrated polling logic from CurrencyUpdateWorker into repository init block; added remoteConfigSource and peerManagerSource dependencies; implemented adaptive delay based on blockInfo.syncProgress; seeded MutableSharedFlow with cached currencies on creation.
  • LTCPickerBentoViewModel.kt – Removed manual polling loop (5s interval); replaced with reactive collection of ltcRepository.rates SharedFlow; removed fetchAndUpdateRates() method call on currency change (now automatic via flow).
  • BRActivity.java – Removed CurrencyUpdateWorker.start() call and related imports; polling now managed by repository initialization.
  • MainScreen.kt – Added fillMaxSize() modifier to WebModalScreen for Bitrefill web view.
  • WebModalScreen.kt – Enhanced AndroidView setup: added explicit layout params, background color, JavaScript/DOM storage settings; converted to use update block for URL loading; improved WebViewClient with lifecycle callbacks.
  • BWConstants.kt – Removed affiliate parameter from BITREFILL_URL (changed from https://www.bitrefill.com/?ref=bAshL935 to https://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 into LtcRepositoryImpl initialization to reduce architectural complexity and enable remote config control.

📊 Statistics

  • Additions: 184 lines
  • Deletions: 104 lines
  • Files Changed: 11
  • Commits: 2

🔗 Related Issues

  • Fixes # (techdebt/sync reduce rate fpf)
  • Related to #

🧪 Tests Status

  • Tests ran successfully locally?
  • Added more tests? How many?
  • Code coverage percentage of the codebase: __%

📸 Screenshots/Videos

Before After
Add screenshot Add screenshot

🎯 Reviewers

@kcw-grunt, @josikie


Draft Status: This PR is currently in draft mode and ready for review feedback.


⚠️ Review Notes

  • Architecture: Polling moved from Worker pattern to repository initialization—ensure proper coroutine scope lifecycle and cancellation during app termination.
  • Remote Config: JSON parsing expects exact schema (sync_delay, non_sync_delay keys); validate Firebase Remote Config default matches.
  • SharedFlow vs StateFlow: Late collectors won't replay history. Verify UI components handle the first emission correctly.
  • Sync Progress Logic: Polling delays adapts based on blockInfo.syncProgress <= 0.95f; confirm this threshold aligns with product requirements.
  • WebView Changes: Removed LocalContext.current reference and improved configuration; test cross-platform WebView behavior on different Android versions.
  • Timber Logging: Added debug logging (timber|| rates in fetching, timber|| duration in fetching)—remove or adjust log level for production.

@kcw-grunt kcw-grunt changed the title Techdebt/sync reduce rate fpf 🧼 Techdebt/sync reduce rate fpf May 1, 2026
@kcw-grunt
kcw-grunt merged commit 734b3d7 into develop May 1, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant