Updated on 2026-08-14
This commit is contained in:
parent
2d28d399ca
commit
092f5be9f7
10 changed files with 173 additions and 47 deletions
|
|
@ -62,7 +62,28 @@ internal class DefaultNetworksStatusesStore(
|
|||
}
|
||||
|
||||
override suspend fun getSyncOrNull(key: UserWalletId): Set<NetworkStatus>? {
|
||||
return runtimeDataStore.getSyncOrNull(key = provideStringKey(key))
|
||||
val runtimeStatuses = runtimeDataStore.getSyncOrNull(key = provideStringKey(key)) ?: return null
|
||||
|
||||
val networks = runtimeStatuses.map(NetworkStatus::network).toSet()
|
||||
|
||||
val cachedStatuses = persistenceDataStore.data.firstOrNull()
|
||||
?.get(key.stringValue)
|
||||
?.mapNotNullTo(mutableSetOf()) { cached ->
|
||||
val network = networks.firstOrNull {
|
||||
it.id == cached.networkId &&
|
||||
it.derivationPath == NetworkDerivationPathConverter.convert(cached.derivationPath)
|
||||
}
|
||||
?: return@mapNotNullTo null
|
||||
|
||||
NetworkStatusConverter(network = network, isCached = true).convert(value = cached)
|
||||
}
|
||||
.orEmpty()
|
||||
|
||||
return mergeStatuses(
|
||||
networks = networks,
|
||||
cachedStatuses = cachedStatuses,
|
||||
runtimeStatuses = runtimeStatuses,
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun store(key: UserWalletId, value: NetworkStatus) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue