diff --git a/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownFullModule.kt b/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownFullModule.kt
index a7ff47a32c..021e90d6a1 100644
--- a/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownFullModule.kt
+++ b/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownFullModule.kt
@@ -12,7 +12,7 @@ import io.noties.markwon.html.HtmlPlugin
import io.noties.markwon.image.coil.CoilImagesPlugin
import io.noties.markwon.linkify.LinkifyPlugin
import io.novafoundation.nova.common.di.scope.ScreenScope
-import io.novafoundation.nova.common.utils.markdown.StylePlugin
+import io.novafoundation.nova.common.utils.markdown.LinkStylePlugin
@Module
class MarkdownFullModule {
@@ -22,7 +22,7 @@ class MarkdownFullModule {
fun provideMarkwon(context: Context, imageLoader: ImageLoader): Markwon {
return Markwon.builder(context)
.usePlugin(LinkifyPlugin.create(Linkify.EMAIL_ADDRESSES or Linkify.WEB_URLS))
- .usePlugin(StylePlugin(context))
+ .usePlugin(LinkStylePlugin(context))
.usePlugin(CoilImagesPlugin.create(context, imageLoader))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(TablePlugin.create(context))
diff --git a/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownShortModule.kt b/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownShortModule.kt
index 1e99ea3d23..8b7c46127d 100644
--- a/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownShortModule.kt
+++ b/common/src/main/java/io/novafoundation/nova/common/di/modules/shared/MarkdownShortModule.kt
@@ -10,7 +10,7 @@ import io.noties.markwon.html.HtmlPlugin
import io.noties.markwon.linkify.LinkifyPlugin
import io.novafoundation.nova.common.di.scope.ScreenScope
import io.novafoundation.nova.common.utils.markdown.RemoveHtmlTagsPlugin
-import io.novafoundation.nova.common.utils.markdown.StylePlugin
+import io.novafoundation.nova.common.utils.markdown.LinkStylePlugin
private const val IMG_HTML_TAG = "img"
private const val TABLE_HTML_TAG = "table"
@@ -24,7 +24,7 @@ class MarkdownShortModule {
return Markwon.builder(context)
.usePlugin(RemoveHtmlTagsPlugin(IMG_HTML_TAG, TABLE_HTML_TAG))
.usePlugin(LinkifyPlugin.create(Linkify.EMAIL_ADDRESSES or Linkify.WEB_URLS))
- .usePlugin(StylePlugin(context))
+ .usePlugin(LinkStylePlugin(context))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(HtmlPlugin.create())
.build()
diff --git a/common/src/main/java/io/novafoundation/nova/common/utils/markdown/BoldStylePlugin.kt b/common/src/main/java/io/novafoundation/nova/common/utils/markdown/BoldStylePlugin.kt
new file mode 100644
index 0000000000..175aa58839
--- /dev/null
+++ b/common/src/main/java/io/novafoundation/nova/common/utils/markdown/BoldStylePlugin.kt
@@ -0,0 +1,36 @@
+package io.novafoundation.nova.common.utils.markdown
+
+import android.content.Context
+import androidx.annotation.ColorRes
+import androidx.annotation.FontRes
+import androidx.core.content.res.ResourcesCompat
+import io.noties.markwon.AbstractMarkwonPlugin
+import io.noties.markwon.MarkwonConfiguration
+import io.noties.markwon.MarkwonSpansFactory
+import io.noties.markwon.RenderProps
+import io.noties.markwon.SpanFactory
+import io.novafoundation.nova.common.utils.colorSpan
+import io.novafoundation.nova.common.utils.fontSpan
+import org.commonmark.node.StrongEmphasis
+
+class BoldStylePlugin(
+ private val context: Context,
+ @FontRes private val typefaceRes: Int,
+ @ColorRes private val colorRes: Int
+) : AbstractMarkwonPlugin() {
+
+ override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) {
+ builder.setFactory(StrongEmphasis::class.java, BoldSpanFactory(context, typefaceRes, colorRes))
+ }
+}
+
+private class BoldSpanFactory(private val context: Context, private val typefaceRes: Int, private val colorRes: Int) : SpanFactory {
+
+ override fun getSpans(configuration: MarkwonConfiguration, props: RenderProps): Any {
+ val font = ResourcesCompat.getFont(context, typefaceRes)
+ return arrayOf(
+ fontSpan(font),
+ colorSpan(context.getColor(colorRes))
+ )
+ }
+}
diff --git a/common/src/main/java/io/novafoundation/nova/common/utils/markdown/StylePlugin.kt b/common/src/main/java/io/novafoundation/nova/common/utils/markdown/LinkStylePlugin.kt
similarity index 83%
rename from common/src/main/java/io/novafoundation/nova/common/utils/markdown/StylePlugin.kt
rename to common/src/main/java/io/novafoundation/nova/common/utils/markdown/LinkStylePlugin.kt
index 35342a35aa..20dd2afce4 100644
--- a/common/src/main/java/io/novafoundation/nova/common/utils/markdown/StylePlugin.kt
+++ b/common/src/main/java/io/novafoundation/nova/common/utils/markdown/LinkStylePlugin.kt
@@ -5,7 +5,7 @@ import io.noties.markwon.AbstractMarkwonPlugin
import io.noties.markwon.core.MarkwonTheme
import io.novafoundation.nova.common.R
-class StylePlugin(private val context: Context) : AbstractMarkwonPlugin() {
+class LinkStylePlugin(private val context: Context) : AbstractMarkwonPlugin() {
override fun configureTheme(builder: MarkwonTheme.Builder) {
builder.isLinkUnderlined(false)
diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml
index d4a61eff3a..65457f8835 100644
--- a/common/src/main/res/values/colors.xml
+++ b/common/src/main/res/values/colors.xml
@@ -36,6 +36,7 @@
#A3FFFFFF
#A3FFFFFF
#52FFFFFF
+ #A3FFFFFF
#BD387F
#FF7A00
diff --git a/feature-governance-api/src/main/java/io/novafoundation/nova/feature_governance_api/domain/tindergov/TinderGovInteractor.kt b/feature-governance-api/src/main/java/io/novafoundation/nova/feature_governance_api/domain/tindergov/TinderGovInteractor.kt
deleted file mode 100644
index e5b0590e07..0000000000
--- a/feature-governance-api/src/main/java/io/novafoundation/nova/feature_governance_api/domain/tindergov/TinderGovInteractor.kt
+++ /dev/null
@@ -1,56 +0,0 @@
-package io.novafoundation.nova.feature_governance_api.domain.tindergov
-
-import io.novafoundation.nova.feature_governance_api.data.model.TinderGovBasketItem
-import io.novafoundation.nova.feature_governance_api.data.model.VotingPower
-import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
-import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.VoteType
-import io.novafoundation.nova.feature_governance_api.domain.referendum.details.ReferendumCall
-import io.novafoundation.nova.feature_governance_api.domain.referendum.list.ReferendaState
-import io.novafoundation.nova.feature_governance_api.domain.referendum.list.ReferendumPreview
-import io.novafoundation.nova.runtime.multiNetwork.chain.model.ChainId
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.Flow
-
-sealed interface VotingPowerState {
-
- object Empty : VotingPowerState
-
- class InsufficientAmount(val votingPower: VotingPower) : VotingPowerState
-
- class SufficientAmount(val votingPower: VotingPower) : VotingPowerState
-}
-
-interface TinderGovInteractor {
-
- fun observeReferendaState(coroutineScope: CoroutineScope): Flow
-
- fun observeReferendaAvailableToVote(coroutineScope: CoroutineScope): Flow>
-
- fun observeTinderGovBasket(): Flow>
-
- suspend fun getTinderGovBasket(): List
-
- suspend fun addItemToBasket(referendumId: ReferendumId, voteType: VoteType)
-
- suspend fun loadReferendumSummary(id: ReferendumId): String?
-
- suspend fun loadReferendumAmount(referendumPreview: ReferendumPreview): ReferendumCall.TreasuryRequest?
-
- suspend fun setVotingPower(votingPower: VotingPower)
-
- suspend fun getVotingPower(metaId: Long, chainId: ChainId): VotingPower?
-
- suspend fun getVotingPowerState(): VotingPowerState
-
- suspend fun removeReferendumFromBasket(item: TinderGovBasketItem)
-
- suspend fun removeBasketItems(items: Collection)
-
- suspend fun isBasketEmpty(): Boolean
-
- suspend fun clearBasket()
-
- suspend fun getBasketItemsToRemove(coroutineScope: CoroutineScope): List
-
- suspend fun awaitAllItemsVoted(coroutineScope: CoroutineScope, basket: List)
-}
diff --git a/feature-governance-impl/build.gradle b/feature-governance-impl/build.gradle
index 732507ae42..8786c21eaa 100644
--- a/feature-governance-impl/build.gradle
+++ b/feature-governance-impl/build.gradle
@@ -18,8 +18,6 @@ android {
buildConfigField "String", "GOVERNANCE_DAPPS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/governance/v2/dapps_dev.json\""
buildConfigField "String", "DELEGATION_TUTORIAL_URL", "\"https://docs.novawallet.io/nova-wallet-wiki/governance/add-delegate-information\""
-
- buildConfigField "String", "SUMMARY_API_KEY", readStringSecret("POLKASSEMBLY_SUMMARY_API_KEY")
}
buildTypes {
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryApi.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryApi.kt
index 27762de251..a2058632f0 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryApi.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryApi.kt
@@ -1,18 +1,16 @@
package io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2
-import retrofit2.http.GET
-import retrofit2.http.Header
-import retrofit2.http.Query
+import io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.request.ReferendumSummariesRequest
+import io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.response.ReferendumSummaryResponse
+import retrofit2.http.Body
+import retrofit2.http.POST
import retrofit2.http.Url
interface ReferendumSummaryApi {
- @GET
- suspend fun getReferendumSummary(
+ @POST
+ suspend fun getReferendumSummaries(
@Url url: String,
- @Header("x-network") networkHeader: String?,
- @Header("x-ai-summary-api-key") summaryApiKey: String,
- @Query("postId") postId: Int,
- @Query("proposalType") proposalType: String = "referendums_v2"
- ): ReferendumSummaryResponse
+ @Body body: ReferendumSummariesRequest
+ ): List
}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryDataSource.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryDataSource.kt
index f54d2ec555..3db1a4fa60 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryDataSource.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryDataSource.kt
@@ -1,27 +1,32 @@
package io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2
import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
-import io.novafoundation.nova.feature_governance_impl.BuildConfig
+import io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.request.ReferendumSummariesRequest
import io.novafoundation.nova.runtime.ext.summaryApiOrNull
import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain
interface ReferendumSummaryDataSource {
- suspend fun loadSummary(chain: Chain, id: ReferendumId, baseUrl: String): String
+ suspend fun loadSummaries(chain: Chain, ids: List, languageCode: String): Map?
}
class RealReferendumSummaryDataSource(
val api: ReferendumSummaryApi
) : ReferendumSummaryDataSource {
- override suspend fun loadSummary(chain: Chain, id: ReferendumId, baseUrl: String): String {
- val externalApi = chain.summaryApiOrNull()!!
+ override suspend fun loadSummaries(chain: Chain, ids: List, languageCode: String): Map? {
+ val summaryApi = chain.summaryApiOrNull() ?: return null
- return api.getReferendumSummary(
- baseUrl,
- networkHeader = externalApi.network,
- summaryApiKey = BuildConfig.SUMMARY_API_KEY,
- postId = id.value.toInt()
- ).summary
+ val response = api.getReferendumSummaries(
+ summaryApi.url,
+ ReferendumSummariesRequest(
+ chainId = chain.id,
+ languageIsoCode = languageCode,
+ referendumIds = ids.map { it.value.toString() }
+ )
+ )
+
+ return response.associateBy { ReferendumId(it.referendumId.toBigInteger()) }
+ .mapValues { it.value.summary }
}
}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryResponse.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryResponse.kt
deleted file mode 100644
index 1e5beed9e8..0000000000
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/ReferendumSummaryResponse.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2
-
-class ReferendumSummaryResponse(val summary: String)
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/request/ReferendumSummariesRequest.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/request/ReferendumSummariesRequest.kt
new file mode 100644
index 0000000000..ac7acfa234
--- /dev/null
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/request/ReferendumSummariesRequest.kt
@@ -0,0 +1,7 @@
+package io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.request
+
+class ReferendumSummariesRequest(
+ val chainId: String,
+ val languageIsoCode: String,
+ val referendumIds: List
+)
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/response/ReferendumSummaryResponse.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/response/ReferendumSummaryResponse.kt
new file mode 100644
index 0000000000..d1fcb1ec92
--- /dev/null
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/offchain/referendum/summary/v2/response/ReferendumSummaryResponse.kt
@@ -0,0 +1,3 @@
+package io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.response
+
+class ReferendumSummaryResponse(val referendumId: Int, val summary: String)
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/modules/screens/TinderGovModule.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/modules/screens/TinderGovModule.kt
index 1027cd974c..b02d0df8b5 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/modules/screens/TinderGovModule.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/modules/screens/TinderGovModule.kt
@@ -2,11 +2,14 @@ package io.novafoundation.nova.feature_governance_impl.di.modules.screens
import dagger.Module
import dagger.Provides
+import io.novafoundation.nova.common.data.memory.ComputationalCache
import io.novafoundation.nova.common.data.network.NetworkApiCreator
import io.novafoundation.nova.common.di.scope.FeatureScope
import io.novafoundation.nova.core_db.dao.TinderGovDao
import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository
-import io.novafoundation.nova.feature_governance_api.domain.tindergov.TinderGovInteractor
+import io.novafoundation.nova.feature_governance_impl.domain.summary.ReferendaSummaryInteractor
+import io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.TinderGovBasketInteractor
+import io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.TinderGovInteractor
import io.novafoundation.nova.feature_governance_impl.data.GovernanceSharedState
import io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.RealReferendumSummaryDataSource
import io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.ReferendumSummaryApi
@@ -20,9 +23,11 @@ import io.novafoundation.nova.feature_governance_impl.domain.referendum.details.
import io.novafoundation.nova.feature_governance_impl.domain.referendum.details.call.ReferendumPreImageParser
import io.novafoundation.nova.feature_governance_impl.domain.referendum.list.ReferendaSharedComputation
import io.novafoundation.nova.feature_governance_impl.domain.referendum.list.filtering.ReferendaFilteringProvider
+import io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.RealTinderGovBasketInteractor
import io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.RealTinderGovInteractor
+import io.novafoundation.nova.feature_governance_impl.domain.summary.RealReferendaSummaryInteractor
+import io.novafoundation.nova.feature_governance_impl.domain.summary.ReferendaSummarySharedComputation
import io.novafoundation.nova.feature_wallet_api.domain.AssetUseCase
-import io.novafoundation.nova.feature_wallet_api.domain.interfaces.WalletRepository
@Module
class TinderGovModule {
@@ -69,10 +74,7 @@ class TinderGovModule {
governanceSharedState: GovernanceSharedState,
referendaSharedComputation: ReferendaSharedComputation,
accountRepository: AccountRepository,
- referendumDetailsRepository: ReferendumDetailsRepository,
preImageParser: ReferendumPreImageParser,
- tinderGovBasketRepository: TinderGovBasketRepository,
- walletRepository: WalletRepository,
tinderGovVotingPowerRepository: TinderGovVotingPowerRepository,
referendaFilteringProvider: ReferendaFilteringProvider,
assetUseCase: AssetUseCase
@@ -80,12 +82,53 @@ class TinderGovModule {
governanceSharedState,
referendaSharedComputation,
accountRepository,
- referendumDetailsRepository,
preImageParser,
- tinderGovBasketRepository,
- walletRepository,
tinderGovVotingPowerRepository,
referendaFilteringProvider,
assetUseCase
)
+
+ @Provides
+ @FeatureScope
+ fun provideReferendaSummarySharedComputation(
+ computationalCache: ComputationalCache,
+ referendumDetailsRepository: ReferendumDetailsRepository,
+ accountRepository: AccountRepository
+ ) = ReferendaSummarySharedComputation(
+ computationalCache,
+ referendumDetailsRepository,
+ accountRepository
+ )
+
+ @Provides
+ @FeatureScope
+ fun provideReferendaSummaryInteractor(
+ governanceSharedState: GovernanceSharedState,
+ referendaSummarySharedComputation: ReferendaSummarySharedComputation
+ ): ReferendaSummaryInteractor = RealReferendaSummaryInteractor(
+ governanceSharedState,
+ referendaSummarySharedComputation
+ )
+
+ @Provides
+ @FeatureScope
+ fun provideTinderGovBasketInteractor(
+ governanceSharedState: GovernanceSharedState,
+ referendaSharedComputation: ReferendaSharedComputation,
+ accountRepository: AccountRepository,
+ tinderGovBasketRepository: TinderGovBasketRepository,
+ tinderGovVotingPowerRepository: TinderGovVotingPowerRepository,
+ referendaFilteringProvider: ReferendaFilteringProvider,
+ assetUseCase: AssetUseCase,
+ tinderGovInteractor: TinderGovInteractor
+ ): TinderGovBasketInteractor = RealTinderGovBasketInteractor(
+ governanceSharedState = governanceSharedState,
+ referendaSharedComputation = referendaSharedComputation,
+ accountRepository = accountRepository,
+ tinderGovBasketRepository = tinderGovBasketRepository,
+ tinderGovVotingPowerRepository = tinderGovVotingPowerRepository,
+ referendaFilteringProvider = referendaFilteringProvider,
+ assetUseCase = assetUseCase,
+ tinderGovInteractor = tinderGovInteractor
+ )
}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/details/ReferendumDetailsRepository.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/details/ReferendumDetailsRepository.kt
index e3aaf1dcd4..92d366a975 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/details/ReferendumDetailsRepository.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/details/ReferendumDetailsRepository.kt
@@ -1,19 +1,20 @@
package io.novafoundation.nova.feature_governance_impl.domain.referendum.details
+import io.novafoundation.nova.core.model.Language
import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
import io.novafoundation.nova.feature_governance_impl.data.offchain.referendum.summary.v2.ReferendumSummaryDataSource
import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain
interface ReferendumDetailsRepository {
- suspend fun loadSummary(chain: Chain, id: ReferendumId, baseUrl: String): String
+ suspend fun loadSummaries(chain: Chain, ids: List, selectedLanguage: Language): Map?
}
class RealReferendumDetailsRepository(
private val referendumSummaryDataSource: ReferendumSummaryDataSource
) : ReferendumDetailsRepository {
- override suspend fun loadSummary(chain: Chain, id: ReferendumId, baseUrl: String): String {
- return referendumSummaryDataSource.loadSummary(chain, id, baseUrl)
+ override suspend fun loadSummaries(chain: Chain, ids: List, selectedLanguage: Language): Map? {
+ return referendumSummaryDataSource.loadSummaries(chain, ids, selectedLanguage.iso639Code)
}
}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/TinderGovBasketInteractor.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/TinderGovBasketInteractor.kt
new file mode 100644
index 0000000000..76dd09c339
--- /dev/null
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/TinderGovBasketInteractor.kt
@@ -0,0 +1,144 @@
+package io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov
+
+import io.novafoundation.nova.common.utils.flowOfAll
+import io.novafoundation.nova.common.utils.mapToSet
+import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository
+import io.novafoundation.nova.feature_governance_api.data.model.TinderGovBasketItem
+import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
+import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.VoteType
+import io.novafoundation.nova.feature_governance_impl.data.GovernanceSharedState
+import io.novafoundation.nova.feature_governance_impl.data.repository.tindergov.TinderGovBasketRepository
+import io.novafoundation.nova.feature_governance_impl.data.repository.tindergov.TinderGovVotingPowerRepository
+import io.novafoundation.nova.feature_governance_impl.domain.referendum.list.ReferendaSharedComputation
+import io.novafoundation.nova.feature_governance_impl.domain.referendum.list.filtering.ReferendaFilteringProvider
+import io.novafoundation.nova.feature_wallet_api.domain.AssetUseCase
+import io.novafoundation.nova.feature_wallet_api.domain.getCurrentAsset
+import io.novafoundation.nova.feature_wallet_api.domain.model.Asset
+import io.novafoundation.nova.feature_wallet_api.domain.model.availableToVote
+import io.novafoundation.nova.runtime.state.chain
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.filter
+import kotlinx.coroutines.flow.first
+
+interface TinderGovBasketInteractor {
+
+ fun observeTinderGovBasket(): Flow>
+
+ suspend fun getTinderGovBasket(): List
+
+ suspend fun addItemToBasket(referendumId: ReferendumId, voteType: VoteType)
+
+ suspend fun removeReferendumFromBasket(item: TinderGovBasketItem)
+
+ suspend fun removeBasketItems(items: Collection)
+
+ suspend fun isBasketEmpty(): Boolean
+
+ suspend fun clearBasket()
+
+ suspend fun getBasketItemsToRemove(coroutineScope: CoroutineScope): List
+
+ suspend fun awaitAllItemsVoted(coroutineScope: CoroutineScope, basket: List)
+}
+
+class RealTinderGovBasketInteractor(
+ private val governanceSharedState: GovernanceSharedState,
+ private val referendaSharedComputation: ReferendaSharedComputation,
+ private val accountRepository: AccountRepository,
+ private val tinderGovBasketRepository: TinderGovBasketRepository,
+ private val tinderGovVotingPowerRepository: TinderGovVotingPowerRepository,
+ private val referendaFilteringProvider: ReferendaFilteringProvider,
+ private val assetUseCase: AssetUseCase,
+ private val tinderGovInteractor: TinderGovInteractor
+) : TinderGovBasketInteractor {
+
+ override fun observeTinderGovBasket(): Flow> {
+ return flowOfAll {
+ val metaAccount = accountRepository.getSelectedMetaAccount()
+ val chain = governanceSharedState.chain()
+
+ tinderGovBasketRepository.observeBasket(metaAccount.id, chain.id)
+ }
+ }
+
+ override suspend fun getTinderGovBasket(): List {
+ val metaAccount = accountRepository.getSelectedMetaAccount()
+ val chain = governanceSharedState.chain()
+
+ return tinderGovBasketRepository.getBasket(metaAccount.id, chain.id)
+ }
+
+ override suspend fun addItemToBasket(referendumId: ReferendumId, voteType: VoteType) {
+ val metaAccount = accountRepository.getSelectedMetaAccount()
+ val chain = governanceSharedState.chain()
+
+ val votingPower = tinderGovVotingPowerRepository.getVotingPower(metaAccount.id, chain.id)!!
+
+ tinderGovBasketRepository.add(
+ TinderGovBasketItem(
+ metaId = metaAccount.id,
+ chainId = chain.id,
+ referendumId = referendumId,
+ voteType = voteType,
+ conviction = votingPower.conviction,
+ amount = votingPower.amount
+ )
+ )
+ }
+
+ override suspend fun removeReferendumFromBasket(item: TinderGovBasketItem) {
+ tinderGovBasketRepository.remove(item)
+ }
+
+ override suspend fun removeBasketItems(items: Collection) {
+ tinderGovBasketRepository.remove(items)
+ }
+
+ override suspend fun isBasketEmpty(): Boolean {
+ val metaAccount = accountRepository.getSelectedMetaAccount()
+ val chain = governanceSharedState.chain()
+
+ return tinderGovBasketRepository.isBasketEmpty(metaAccount.id, chain.id)
+ }
+
+ override suspend fun clearBasket() {
+ val metaAccount = accountRepository.getSelectedMetaAccount()
+ val chain = governanceSharedState.chain()
+
+ tinderGovBasketRepository.clearBasket(metaAccount.id, chain.id)
+ }
+
+ override suspend fun getBasketItemsToRemove(coroutineScope: CoroutineScope): List {
+ val metaAccount = accountRepository.getSelectedMetaAccount()
+ val chain = governanceSharedState.chain()
+ val asset = assetUseCase.getCurrentAsset()
+ val basket = tinderGovBasketRepository.getBasket(metaAccount.id, chain.id)
+
+ val availableToVoteReferenda = tinderGovInteractor.observeReferendaAvailableToVote(coroutineScope).first()
+ .mapToSet { it.id }
+
+ return basket.filter { it.isItemNotAvailableToVote(availableToVoteReferenda, asset) }
+ }
+
+ override suspend fun awaitAllItemsVoted(coroutineScope: CoroutineScope, basket: List) {
+ tinderGovInteractor.observeReferendaState(coroutineScope)
+ .filter { referendaState ->
+ val referenda = referendaState.referenda.associateBy { it.id }
+ val allBasketItemsVoted = basket.all {
+ val referendum = referenda[it.referendumId]
+ referendum?.referendumVote != null
+ }
+
+ allBasketItemsVoted
+ }.first()
+ }
+
+ private fun TinderGovBasketItem.isItemNotAvailableToVote(
+ availableToVoteReferenda: Set,
+ asset: Asset
+ ): Boolean {
+ val notEnoughBalance = this.amount > asset.availableToVote()
+ return (this.referendumId !in availableToVoteReferenda) || notEnoughBalance
+ }
+}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/RealTinderGovInteractor.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/TinderGovInteractor.kt
similarity index 60%
rename from feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/RealTinderGovInteractor.kt
rename to feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/TinderGovInteractor.kt
index fe8a9e616b..76beae00a3 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/RealTinderGovInteractor.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/referendum/tindergov/TinderGovInteractor.kt
@@ -2,33 +2,25 @@ package io.novafoundation.nova.feature_governance_impl.domain.referendum.tinderg
import io.novafoundation.nova.common.domain.filterLoaded
import io.novafoundation.nova.common.utils.flowOfAll
-import io.novafoundation.nova.common.utils.mapToSet
import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository
import io.novafoundation.nova.feature_governance_api.data.model.TinderGovBasketItem
import io.novafoundation.nova.feature_governance_api.data.model.VotingPower
import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
-import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.VoteType
import io.novafoundation.nova.feature_governance_api.domain.referendum.details.ReferendumCall
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.ReferendaState
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.ReferendumPreview
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.Voter
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.toCallOrNull
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.user
-import io.novafoundation.nova.feature_governance_api.domain.tindergov.TinderGovInteractor
-import io.novafoundation.nova.feature_governance_api.domain.tindergov.VotingPowerState
import io.novafoundation.nova.feature_governance_impl.data.GovernanceSharedState
-import io.novafoundation.nova.feature_governance_impl.data.repository.tindergov.TinderGovBasketRepository
import io.novafoundation.nova.feature_governance_impl.data.repository.tindergov.TinderGovVotingPowerRepository
-import io.novafoundation.nova.feature_governance_impl.domain.referendum.details.ReferendumDetailsRepository
import io.novafoundation.nova.feature_governance_impl.domain.referendum.details.call.ReferendumPreImageParser
import io.novafoundation.nova.feature_governance_impl.domain.referendum.list.ReferendaSharedComputation
import io.novafoundation.nova.feature_governance_impl.domain.referendum.list.filtering.ReferendaFilteringProvider
import io.novafoundation.nova.feature_wallet_api.domain.AssetUseCase
import io.novafoundation.nova.feature_wallet_api.domain.getCurrentAsset
-import io.novafoundation.nova.feature_wallet_api.domain.interfaces.WalletRepository
import io.novafoundation.nova.feature_wallet_api.domain.model.Asset
import io.novafoundation.nova.feature_wallet_api.domain.model.availableToVote
-import io.novafoundation.nova.runtime.ext.summaryApiOrNull
import io.novafoundation.nova.runtime.multiNetwork.chain.model.ChainId
import io.novafoundation.nova.runtime.state.chain
import io.novafoundation.nova.runtime.state.selectedOption
@@ -38,14 +30,37 @@ import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
+sealed interface VotingPowerState {
+
+ object Empty : VotingPowerState
+
+ class InsufficientAmount(val votingPower: VotingPower) : VotingPowerState
+
+ class SufficientAmount(val votingPower: VotingPower) : VotingPowerState
+}
+
+interface TinderGovInteractor {
+
+ fun observeReferendaState(coroutineScope: CoroutineScope): Flow
+
+ fun observeReferendaAvailableToVote(coroutineScope: CoroutineScope): Flow>
+
+ suspend fun getReferendumAmount(referendumPreview: ReferendumPreview): ReferendumCall.TreasuryRequest?
+
+ suspend fun setVotingPower(votingPower: VotingPower)
+
+ suspend fun getVotingPower(metaId: Long, chainId: ChainId): VotingPower?
+
+ suspend fun getVotingPowerState(): VotingPowerState
+
+ suspend fun awaitAllItemsVoted(coroutineScope: CoroutineScope, basket: List)
+}
+
class RealTinderGovInteractor(
private val governanceSharedState: GovernanceSharedState,
private val referendaSharedComputation: ReferendaSharedComputation,
private val accountRepository: AccountRepository,
- private val referendumDetailsRepository: ReferendumDetailsRepository,
private val preImageParser: ReferendumPreImageParser,
- private val tinderGovBasketRepository: TinderGovBasketRepository,
- private val walletRepository: WalletRepository,
private val tinderGovVotingPowerRepository: TinderGovVotingPowerRepository,
private val referendaFilteringProvider: ReferendaFilteringProvider,
private val assetUseCase: AssetUseCase
@@ -70,47 +85,7 @@ class RealTinderGovInteractor(
.map { filterAvailableToVoteReferenda(it) }
}
- override fun observeTinderGovBasket(): Flow> {
- return flowOfAll {
- val metaAccount = accountRepository.getSelectedMetaAccount()
- val chain = governanceSharedState.chain()
-
- tinderGovBasketRepository.observeBasket(metaAccount.id, chain.id)
- }
- }
-
- override suspend fun getTinderGovBasket(): List {
- val metaAccount = accountRepository.getSelectedMetaAccount()
- val chain = governanceSharedState.chain()
-
- return tinderGovBasketRepository.getBasket(metaAccount.id, chain.id)
- }
-
- override suspend fun addItemToBasket(referendumId: ReferendumId, voteType: VoteType) {
- val metaAccount = accountRepository.getSelectedMetaAccount()
- val chain = governanceSharedState.chain()
-
- val votingPower = getVotingPower(metaAccount.id, chain.id)!!
-
- tinderGovBasketRepository.add(
- TinderGovBasketItem(
- metaId = metaAccount.id,
- chainId = chain.id,
- referendumId = referendumId,
- voteType = voteType,
- conviction = votingPower.conviction,
- amount = votingPower.amount
- )
- )
- }
-
- override suspend fun loadReferendumSummary(id: ReferendumId): String? {
- val chain = governanceSharedState.chain()
- val summaryApi = chain.summaryApiOrNull() ?: return null
- return referendumDetailsRepository.loadSummary(chain, id, summaryApi.url)
- }
-
- override suspend fun loadReferendumAmount(referendumPreview: ReferendumPreview): ReferendumCall.TreasuryRequest? {
+ override suspend fun getReferendumAmount(referendumPreview: ReferendumPreview): ReferendumCall.TreasuryRequest? {
val selectedGovernanceOption = governanceSharedState.selectedOption()
val chain = selectedGovernanceOption.assetWithChain.chain
@@ -142,40 +117,6 @@ class RealTinderGovInteractor(
}
}
- override suspend fun removeReferendumFromBasket(item: TinderGovBasketItem) {
- tinderGovBasketRepository.remove(item)
- }
-
- override suspend fun removeBasketItems(items: Collection) {
- tinderGovBasketRepository.remove(items)
- }
-
- override suspend fun isBasketEmpty(): Boolean {
- val metaAccount = accountRepository.getSelectedMetaAccount()
- val chain = governanceSharedState.chain()
-
- return tinderGovBasketRepository.isBasketEmpty(metaAccount.id, chain.id)
- }
-
- override suspend fun clearBasket() {
- val metaAccount = accountRepository.getSelectedMetaAccount()
- val chain = governanceSharedState.chain()
-
- tinderGovBasketRepository.clearBasket(metaAccount.id, chain.id)
- }
-
- override suspend fun getBasketItemsToRemove(coroutineScope: CoroutineScope): List {
- val metaAccount = accountRepository.getSelectedMetaAccount()
- val chain = governanceSharedState.chain()
- val asset = assetUseCase.getCurrentAsset()
- val basket = tinderGovBasketRepository.getBasket(metaAccount.id, chain.id)
-
- val availableToVoteReferenda = observeReferendaAvailableToVote(coroutineScope).first()
- .mapToSet { it.id }
-
- return basket.filter { it.isItemNotAvailableToVote(availableToVoteReferenda, asset) }
- }
-
override suspend fun awaitAllItemsVoted(coroutineScope: CoroutineScope, basket: List) {
observeReferendaState(coroutineScope)
.filter { referendaState ->
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/summary/ReferendaSummaryInteractor.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/summary/ReferendaSummaryInteractor.kt
new file mode 100644
index 0000000000..7f8bc87241
--- /dev/null
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/summary/ReferendaSummaryInteractor.kt
@@ -0,0 +1,28 @@
+package io.novafoundation.nova.feature_governance_impl.domain.summary
+
+import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
+import io.novafoundation.nova.feature_governance_impl.data.GovernanceSharedState
+import io.novafoundation.nova.runtime.state.selectedOption
+import kotlinx.coroutines.CoroutineScope
+
+interface ReferendaSummaryInteractor {
+
+ suspend fun getReferendaSummaries(ids: List, coroutineScope: CoroutineScope): Map
+}
+
+class RealReferendaSummaryInteractor(
+ private val governanceSharedState: GovernanceSharedState,
+ private val referendaSummarySharedComputation: ReferendaSummarySharedComputation
+) : ReferendaSummaryInteractor {
+
+ override suspend fun getReferendaSummaries(ids: List, coroutineScope: CoroutineScope): Map {
+ return runCatching {
+ referendaSummarySharedComputation.summaries(
+ governanceSharedState.selectedOption(),
+ ids,
+ coroutineScope
+ )
+ }.getOrNull()
+ .orEmpty()
+ }
+}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/summary/ReferendaSummarySharedComputation.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/summary/ReferendaSummarySharedComputation.kt
new file mode 100644
index 0000000000..8237e87b3b
--- /dev/null
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/domain/summary/ReferendaSummarySharedComputation.kt
@@ -0,0 +1,30 @@
+package io.novafoundation.nova.feature_governance_impl.domain.summary
+
+import io.novafoundation.nova.common.data.memory.ComputationalCache
+import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository
+import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
+import io.novafoundation.nova.feature_governance_api.data.source.SupportedGovernanceOption
+import io.novafoundation.nova.feature_governance_impl.domain.referendum.details.ReferendumDetailsRepository
+import kotlinx.coroutines.CoroutineScope
+
+class ReferendaSummarySharedComputation(
+ private val computationalCache: ComputationalCache,
+ private val referendumDetailsRepository: ReferendumDetailsRepository,
+ private val accountRepository: AccountRepository
+) {
+
+ suspend fun summaries(
+ governanceOption: SupportedGovernanceOption,
+ referendaIds: List,
+ scope: CoroutineScope
+ ): Map? {
+ val chainId = governanceOption.assetWithChain.chain.id
+ val referendaHashCode = referendaIds.toSet().hashCode()
+ val selectedLanguage = accountRepository.selectedLanguage()
+ val key = "REFERENDA_SUMMARIES:$chainId:$referendaHashCode:${selectedLanguage.iso639Code}"
+
+ return computationalCache.useCache(key, scope) {
+ referendumDetailsRepository.loadSummaries(governanceOption.assetWithChain.chain, referendaIds, selectedLanguage)
+ }
+ }
+}
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionComponent.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionComponent.kt
index b0d00f142b..059aad55b5 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionComponent.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionComponent.kt
@@ -6,6 +6,7 @@ import dagger.Subcomponent
import io.novafoundation.nova.common.di.scope.ScreenScope
import io.novafoundation.nova.feature_governance_impl.presentation.common.info.ReferendumInfoFragment
import io.novafoundation.nova.feature_governance_impl.presentation.common.info.ReferendumInfoPayload
+import io.novafoundation.nova.feature_governance_impl.presentation.common.info.di.ReferendumInfoModule
@Subcomponent(
modules = [
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionModule.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionModule.kt
index 8d153eb1a5..d880690c65 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionModule.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/common/info/di/DescriptionModule.kt
@@ -1,4 +1,4 @@
-package io.novafoundation.nova.feature_governance_impl.presentation.common.description.di
+package io.novafoundation.nova.feature_governance_impl.presentation.common.info.di
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/referenda/list/ReferendaListViewModel.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/referenda/list/ReferendaListViewModel.kt
index 4bde911e6c..176e60a989 100644
--- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/referenda/list/ReferendaListViewModel.kt
+++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/referenda/list/ReferendaListViewModel.kt
@@ -1,7 +1,9 @@
package io.novafoundation.nova.feature_governance_impl.presentation.referenda.list
import android.util.Log
+import androidx.lifecycle.viewModelScope
import io.novafoundation.nova.common.base.BaseViewModel
+import io.novafoundation.nova.common.domain.ExtendedLoadingState
import io.novafoundation.nova.common.domain.dataOrNull
import io.novafoundation.nova.common.list.toListWithHeaders
import io.novafoundation.nova.common.domain.mapLoading
@@ -15,6 +17,7 @@ import io.novafoundation.nova.common.utils.withItemScope
import io.novafoundation.nova.common.view.PlaceholderModel
import io.novafoundation.nova.core.updater.UpdateSystem
import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase
+import io.novafoundation.nova.feature_governance_api.data.network.blockhain.model.ReferendumId
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.DelegatedState
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.GovernanceLocksOverview
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.ReferendaListInteractor
@@ -26,6 +29,7 @@ import io.novafoundation.nova.feature_governance_impl.domain.filters.ReferendaFi
import io.novafoundation.nova.feature_governance_api.domain.referendum.filters.ReferendumType
import io.novafoundation.nova.feature_governance_api.domain.referendum.filters.ReferendumTypeFilter
import io.novafoundation.nova.feature_governance_api.domain.referendum.list.ReferendaListState
+import io.novafoundation.nova.feature_governance_impl.domain.summary.ReferendaSummaryInteractor
import io.novafoundation.nova.feature_governance_impl.presentation.GovernanceRouter
import io.novafoundation.nova.feature_governance_impl.presentation.referenda.common.ReferendumFormatter
import io.novafoundation.nova.feature_governance_impl.presentation.referenda.common.list.ReferendaListStateModel
@@ -59,7 +63,8 @@ class ReferendaListViewModel(
private val updateSystem: UpdateSystem,
private val governanceRouter: GovernanceRouter,
private val referendumFormatter: ReferendumFormatter,
- private val governanceDAppsInteractor: GovernanceDAppsInteractor
+ private val governanceDAppsInteractor: GovernanceDAppsInteractor,
+ private val referendaSummaryInteractor: ReferendaSummaryInteractor
) : BaseViewModel(), WithAssetSelector {
override val assetSelectorMixin = assetSelectorFactory.create(
@@ -103,9 +108,14 @@ class ReferendaListViewModel(
.inBackground()
.shareWhileSubscribed()
- val tinderGovBanner = referendaListStateFlow.map { referenda ->
+ private val referendaSummariesFlow = referendaListStateFlow.mapLoading { referenda ->
+ val referendaIds = referenda.availableToVoteReferenda.map { it.id }
+ referendaSummaryInteractor.getReferendaSummaries(referendaIds, viewModelScope)
+ }.shareInBackground()
+
+ val tinderGovBanner = referendaSummariesFlow.map { summaries ->
val chain = selectedAssetSharedState.chain()
- mapTinderGovToUi(chain, referenda.dataOrNull)
+ mapTinderGovToUi(chain, summaries)
}
.inBackground()
.shareWhileSubscribed()
@@ -170,17 +180,16 @@ class ReferendaListViewModel(
}
}
- private fun mapTinderGovToUi(chain: Chain, referendaListState: ReferendaListState?): TinderGovBannerModel? {
+ private fun mapTinderGovToUi(chain: Chain, referendaSummariesLoadingState: ExtendedLoadingState