mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-04-21 23:48:00 +00:00
fix: auto-refresh Pezkuwi dashboard card after actions
Add dashboardRefreshSignal to trigger re-fetch on swipe-to-refresh, onResume, citizenship bottom sheet dismiss, and score tracking. Rename button label to "Apply & Actions (KYC)" for clarity.
This commit is contained in:
@@ -2764,7 +2764,7 @@
|
||||
|
||||
<string name="pezkuwi_dashboard_title">Pezkuwi</string>
|
||||
<string name="pezkuwi_dashboard_trust_score">Trust Score</string>
|
||||
<string name="pezkuwi_dashboard_basvuru">Apply & Actions</string>
|
||||
<string name="pezkuwi_dashboard_basvuru">Apply & Actions (KYC)</string>
|
||||
<string name="pezkuwi_dashboard_info">Use our Telegram MiniApp for Digital Kurdistan citizenship services.\n\nTo earn PEZ rewards, you must hold a Welatî ticket and stake at least 10 HEZ.\n\nNon-citizens can only benefit from HEZ rewards.</string>
|
||||
<string name="pezkuwi_dashboard_start_tracking">Start Tracking</string>
|
||||
<string name="pezkuwi_dashboard_tracking_success">Score tracking started!</string>
|
||||
|
||||
+9
@@ -120,10 +120,19 @@ class BalanceListFragment :
|
||||
.inject(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refreshDashboard()
|
||||
}
|
||||
|
||||
override fun subscribe(viewModel: BalanceListViewModel) {
|
||||
setupBuySellSelectorMixin(viewModel.buySellSelectorMixin)
|
||||
observeBrowserEvents(viewModel)
|
||||
|
||||
childFragmentManager.setFragmentResultListener("citizenship_dismissed", viewLifecycleOwner) { _, _ ->
|
||||
viewModel.refreshDashboard()
|
||||
}
|
||||
|
||||
viewModel.pezkuwiDashboardFlow.observe { model ->
|
||||
if (model != null) {
|
||||
pezkuwiDashboardAdapter.setModel(model)
|
||||
|
||||
+10
-2
@@ -73,6 +73,7 @@ import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain
|
||||
import io.novasama.substrate_sdk_android.runtime.extrinsic.call
|
||||
import java.text.NumberFormat
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
@@ -135,6 +136,8 @@ class BalanceListViewModel(
|
||||
private val _trackingLoading = MutableLiveData(false)
|
||||
val trackingLoading: LiveData<Boolean> = _trackingLoading
|
||||
|
||||
private val dashboardRefreshSignal = MutableStateFlow(0)
|
||||
|
||||
val bannersMixin = promotionBannersMixinFactory.create(bannerSourceFactory.assetsSource(), viewModelScope)
|
||||
|
||||
private val selectedCurrency = currencyInteractor.observeSelectCurrency()
|
||||
@@ -245,6 +248,7 @@ class BalanceListViewModel(
|
||||
.shareInBackground()
|
||||
|
||||
val pezkuwiDashboardFlow = selectedMetaAccount
|
||||
.combine(dashboardRefreshSignal) { account, _ -> account }
|
||||
.mapLatest { metaAccount ->
|
||||
pezkuwiDashboardInteractor.getDashboard(metaAccount)
|
||||
.map { data ->
|
||||
@@ -291,11 +295,15 @@ class BalanceListViewModel(
|
||||
fun fullSync() {
|
||||
viewModelScope.launch {
|
||||
syncWith(fullSyncActions, selectedMetaAccount.first())
|
||||
|
||||
refreshDashboard()
|
||||
_hideRefreshEvent.value = Event(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshDashboard() {
|
||||
dashboardRefreshSignal.value++
|
||||
}
|
||||
|
||||
fun assetClicked(asset: Chain.Asset) {
|
||||
val payload = AssetPayload(
|
||||
chainId = asset.chainId,
|
||||
@@ -455,7 +463,7 @@ class BalanceListViewModel(
|
||||
}
|
||||
result.getOrThrow()
|
||||
_showTrackingSuccessEvent.postValue(Event(Unit))
|
||||
fullSync()
|
||||
refreshDashboard()
|
||||
} catch (e: Exception) {
|
||||
showError(e.message ?: "Score tracking failed")
|
||||
} finally {
|
||||
|
||||
+6
@@ -1,5 +1,6 @@
|
||||
package io.novafoundation.nova.feature_assets.presentation.citizenship
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
@@ -34,6 +35,11 @@ class CitizenshipBottomSheet : BaseBottomSheetFragment<CitizenshipViewModel, Fra
|
||||
|
||||
override fun createBinding() = FragmentCitizenshipBottomSheetBinding.inflate(layoutInflater)
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
parentFragmentManager.setFragmentResult("citizenship_dismissed", android.os.Bundle.EMPTY)
|
||||
}
|
||||
|
||||
override fun inject() {
|
||||
FeatureUtils.getFeature<AssetsFeatureComponent>(
|
||||
requireContext(),
|
||||
|
||||
Reference in New Issue
Block a user