Skip to content

Commit f7516df

Browse files
authored
Fixing a race condition of incentive points display (#801)
1 parent 1db6139 commit f7516df

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ allprojects {
5252
}
5353

5454
group = "exchange.dydx.abacus"
55-
version = "1.12.73"
55+
version = "1.12.74"
5656

5757
repositories {
5858
google()

src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,29 @@ internal class StateManagerAdaptorV2(
149149
delegate = this,
150150
)
151151

152-
private val system = SystemSupervisor(
152+
private val accounts = AccountsSupervisor(
153153
stateMachine = stateMachine,
154154
helper = networkHelper,
155155
analyticsUtils = analyticsUtils,
156-
configs = appConfigs.systemConfigs,
156+
configs = appConfigs.accountConfigs,
157+
screening = appConfigs.screening,
157158
)
158159

159-
private val onboarding = OnboardingSupervisor(
160+
private val system = SystemSupervisor(
160161
stateMachine = stateMachine,
161162
helper = networkHelper,
162163
analyticsUtils = analyticsUtils,
163-
configs = appConfigs.onboardingConfigs,
164+
configs = appConfigs.systemConfigs,
165+
incentiveSeasonReceived = {
166+
accounts.currentIncentiveSeason = it
167+
},
164168
)
165169

166-
private val accounts = AccountsSupervisor(
170+
private val onboarding = OnboardingSupervisor(
167171
stateMachine = stateMachine,
168172
helper = networkHelper,
169173
analyticsUtils = analyticsUtils,
170-
configs = appConfigs.accountConfigs,
171-
screening = appConfigs.screening,
174+
configs = appConfigs.onboardingConfigs,
172175
)
173176

174177
private val markets = MarketsSupervisor(

src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/AccountSupervisor.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ internal open class AccountSupervisor(
8484
) : DynamicNetworkSupervisor(stateMachine, helper, analyticsUtils) {
8585
val subaccounts = mutableMapOf<Int, SubaccountSupervisor>()
8686

87+
var currentIncentiveSeason: String? = null
88+
set(value) {
89+
if (field != value) {
90+
field = value
91+
retrieveLaunchIncentivePoints()
92+
}
93+
}
94+
8795
private val accountBalancePollingDuration = 10.0
8896
private var accountBalancesTimer: LocalTimerProtocol? = null
8997
set(value) {

src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/AccountsSupervisor.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ internal class AccountsSupervisor(
4646
private var pushNotificationToken: String? = null
4747
private var pushNotificationLanguageCode: String? = null
4848

49+
var currentIncentiveSeason: String? = null
50+
set(value) {
51+
if (field != value) {
52+
field = value
53+
for (account in accounts.values) {
54+
account.currentIncentiveSeason = value
55+
}
56+
}
57+
}
58+
4959
internal var historicalPnlPeriod: HistoricalPnlPeriod
5060
get() {
5161
return when (stateMachine.historicalPnlDays) {

src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SystemSupervisor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ internal class SystemSupervisor(
2424
helper: NetworkHelper,
2525
analyticsUtils: AnalyticsUtils,
2626
internal val configs: SystemConfigs,
27+
private val incentiveSeasonReceived: (String?) -> Unit,
2728
) : NetworkSupervisor(stateMachine, helper, analyticsUtils) {
2829
override fun didSetReadyToConnect(readyToConnect: Boolean) {
2930
super.didSetReadyToConnect(readyToConnect)
@@ -178,7 +179,7 @@ internal class SystemSupervisor(
178179
val oldState = stateMachine.state
179180
update(stateMachine.launchIncentiveSeasons(response), oldState)
180181

181-
// retrieveLaunchIncentivePoints()
182+
incentiveSeasonReceived(stateMachine.state?.launchIncentive?.currentSeason)
182183
}
183184
}
184185
}

v4_abacus.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'v4_abacus'
3-
spec.version = '1.12.73'
3+
spec.version = '1.12.74'
44
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
55
spec.source = { :http=> ''}
66
spec.authors = ''

0 commit comments

Comments
 (0)