Skip to content

Commit 7014039

Browse files
committed
chore(flipcash/pools): internally fetch latest pool when resolving
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent c8fa515 commit 7014039

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

apps/flipcash/features/pools/src/main/kotlin/com/flipcash/app/pools/internal/betting/PoolBettingViewModel.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,7 @@ internal class PoolBettingViewModel @Inject constructor(
421421
).fold(
422422
onSuccess = {
423423
poolsCoordinator.resolvePool(
424-
// ensure the pool metadata is as up-to-date as possible
425-
// ensuring there is no race condition possibility w/ observe
426-
pool = stateFlow.value.metadata.copy(
427-
isOpen = false,
428-
closedAt = it
429-
),
424+
poolId = stateFlow.value.metadata.id,
430425
rendezvous = rendezvous,
431426
resolution = resolution,
432427
)

apps/flipcash/shared/pools/src/main/kotlin/com/flipcash/app/pools/PoolsCoordinator.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,21 @@ class PoolsCoordinator @Inject constructor(
146146
}
147147

148148
suspend fun resolvePool(
149-
pool: Pool,
149+
poolId: ID,
150150
resolution: PoolResolution.DecisionMade,
151151
rendezvous: KeyPair
152152
): Result<Unit> {
153-
val metadata = domainToNetworkMapper.map(pool)
154-
return controller.resolvePool(
155-
pool = metadata,
156-
rendezvous = rendezvous,
157-
resolution = PoolResolutionConverter.toPoolResolution(resolution as PoolResolution),
158-
).onSuccess {
159-
dataSource.resolvePool(pool.id, resolution)
160-
}
153+
return controller.getPool(poolId)
154+
.fold(
155+
onSuccess = {
156+
controller.resolvePool(
157+
pool = it.metadata,
158+
rendezvous = rendezvous,
159+
resolution = PoolResolutionConverter.toPoolResolution(resolution as PoolResolution),
160+
)
161+
},
162+
onFailure = { Result.failure(it) }
163+
)
161164
}
162165

163166
suspend fun placeBet(

0 commit comments

Comments
 (0)