fix(wallet): refresh perps positions on home#6468
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a periodic refresh loop for Perps positions while the Privacy wallet home is visible, and ensures the loop is stopped when the wallet UI is hidden or paused.
Changes:
- Start a 3s refresh loop for Perps positions when
WalletHomePrivacyFragmentis resumed/visible. - Stop the refresh loop when the privacy wallet home is hidden, paused, or its view is destroyed.
- Wire
WalletFragmentvisibility changes to start/stop the privacy wallet refresh behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/src/main/java/one/mixin/android/ui/wallet/WalletHomePrivacyFragment.kt | Adds coroutine-driven periodic enqueueing of RefreshPerpsPositionsJob with start/stop tied to fragment visibility/lifecycle. |
| app/src/main/java/one/mixin/android/ui/wallet/WalletFragment.kt | Ensures the privacy wallet fragment’s refresh loop starts/stops appropriately when the parent wallet fragment is shown/hidden/resumed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+712
to
+725
| private fun startPerpsPositionsRefresh() { | ||
| val walletId = Session.getAccountId().orEmpty() | ||
| if (walletId.isBlank() || !isResumed || isHidden) { | ||
| stopPerpsPositionsRefresh() | ||
| return | ||
| } | ||
| if (perpsPositionsRefreshJob?.isActive == true) return | ||
| perpsPositionsRefreshJob = lifecycleScope.launch { | ||
| while (isActive) { | ||
| jobManager.addJobInBackground(RefreshPerpsPositionsJob(walletId)) | ||
| delay(PERPS_POSITION_REFRESH_INTERVAL_MS) | ||
| } | ||
| } | ||
| } |
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.
Summary