mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-06-18 02:31:09 +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_title">Pezkuwi</string>
|
||||||
<string name="pezkuwi_dashboard_trust_score">Trust Score</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_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_start_tracking">Start Tracking</string>
|
||||||
<string name="pezkuwi_dashboard_tracking_success">Score tracking started!</string>
|
<string name="pezkuwi_dashboard_tracking_success">Score tracking started!</string>
|
||||||
|
|||||||
+9
@@ -120,10 +120,19 @@ class BalanceListFragment :
|
|||||||
.inject(this)
|
.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
viewModel.refreshDashboard()
|
||||||
|
}
|
||||||
|
|
||||||
override fun subscribe(viewModel: BalanceListViewModel) {
|
override fun subscribe(viewModel: BalanceListViewModel) {
|
||||||
setupBuySellSelectorMixin(viewModel.buySellSelectorMixin)
|
setupBuySellSelectorMixin(viewModel.buySellSelectorMixin)
|
||||||
observeBrowserEvents(viewModel)
|
observeBrowserEvents(viewModel)
|
||||||
|
|
||||||
|
childFragmentManager.setFragmentResultListener("citizenship_dismissed", viewLifecycleOwner) { _, _ ->
|
||||||
|
viewModel.refreshDashboard()
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.pezkuwiDashboardFlow.observe { model ->
|
viewModel.pezkuwiDashboardFlow.observe { model ->
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
pezkuwiDashboardAdapter.setModel(model)
|
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 io.novasama.substrate_sdk_android.runtime.extrinsic.call
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.debounce
|
import kotlinx.coroutines.flow.debounce
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
@@ -135,6 +136,8 @@ class BalanceListViewModel(
|
|||||||
private val _trackingLoading = MutableLiveData(false)
|
private val _trackingLoading = MutableLiveData(false)
|
||||||
val trackingLoading: LiveData<Boolean> = _trackingLoading
|
val trackingLoading: LiveData<Boolean> = _trackingLoading
|
||||||
|
|
||||||
|
private val dashboardRefreshSignal = MutableStateFlow(0)
|
||||||
|
|
||||||
val bannersMixin = promotionBannersMixinFactory.create(bannerSourceFactory.assetsSource(), viewModelScope)
|
val bannersMixin = promotionBannersMixinFactory.create(bannerSourceFactory.assetsSource(), viewModelScope)
|
||||||
|
|
||||||
private val selectedCurrency = currencyInteractor.observeSelectCurrency()
|
private val selectedCurrency = currencyInteractor.observeSelectCurrency()
|
||||||
@@ -245,6 +248,7 @@ class BalanceListViewModel(
|
|||||||
.shareInBackground()
|
.shareInBackground()
|
||||||
|
|
||||||
val pezkuwiDashboardFlow = selectedMetaAccount
|
val pezkuwiDashboardFlow = selectedMetaAccount
|
||||||
|
.combine(dashboardRefreshSignal) { account, _ -> account }
|
||||||
.mapLatest { metaAccount ->
|
.mapLatest { metaAccount ->
|
||||||
pezkuwiDashboardInteractor.getDashboard(metaAccount)
|
pezkuwiDashboardInteractor.getDashboard(metaAccount)
|
||||||
.map { data ->
|
.map { data ->
|
||||||
@@ -291,11 +295,15 @@ class BalanceListViewModel(
|
|||||||
fun fullSync() {
|
fun fullSync() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
syncWith(fullSyncActions, selectedMetaAccount.first())
|
syncWith(fullSyncActions, selectedMetaAccount.first())
|
||||||
|
refreshDashboard()
|
||||||
_hideRefreshEvent.value = Event(Unit)
|
_hideRefreshEvent.value = Event(Unit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun refreshDashboard() {
|
||||||
|
dashboardRefreshSignal.value++
|
||||||
|
}
|
||||||
|
|
||||||
fun assetClicked(asset: Chain.Asset) {
|
fun assetClicked(asset: Chain.Asset) {
|
||||||
val payload = AssetPayload(
|
val payload = AssetPayload(
|
||||||
chainId = asset.chainId,
|
chainId = asset.chainId,
|
||||||
@@ -455,7 +463,7 @@ class BalanceListViewModel(
|
|||||||
}
|
}
|
||||||
result.getOrThrow()
|
result.getOrThrow()
|
||||||
_showTrackingSuccessEvent.postValue(Event(Unit))
|
_showTrackingSuccessEvent.postValue(Event(Unit))
|
||||||
fullSync()
|
refreshDashboard()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showError(e.message ?: "Score tracking failed")
|
showError(e.message ?: "Score tracking failed")
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+6
@@ -1,5 +1,6 @@
|
|||||||
package io.novafoundation.nova.feature_assets.presentation.citizenship
|
package io.novafoundation.nova.feature_assets.presentation.citizenship
|
||||||
|
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
@@ -34,6 +35,11 @@ class CitizenshipBottomSheet : BaseBottomSheetFragment<CitizenshipViewModel, Fra
|
|||||||
|
|
||||||
override fun createBinding() = FragmentCitizenshipBottomSheetBinding.inflate(layoutInflater)
|
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() {
|
override fun inject() {
|
||||||
FeatureUtils.getFeature<AssetsFeatureComponent>(
|
FeatureUtils.getFeature<AssetsFeatureComponent>(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
|
|||||||
Reference in New Issue
Block a user