@@ -108,6 +108,8 @@ class RealSessionController @Inject constructor(
108108
109109 private val scannedRendezvous = mutableListOf<String >()
110110
111+ private var welcomeBonus: LocalFiat ? = null
112+
111113 init {
112114 userManager.state
113115 .map { it.isTimelockUnlocked }
@@ -118,7 +120,7 @@ class RealSessionController @Inject constructor(
118120 .mapNotNull { it.authState }
119121 .filter { it.canAccessAuthenticatedApis }
120122 .distinctUntilChanged()
121- .onEach { onAppInForeground(false ) }
123+ .onEach { onAppInForeground() }
122124 .launchIn(scope)
123125
124126 userManager.state
@@ -150,17 +152,15 @@ class RealSessionController @Inject constructor(
150152 * 6. Checks for any pending share actions via the share sheet.
151153 * 7. If the user is registered, connects to the billing client.
152154 */
153- override fun onAppInForeground (checkForAirdrops : Boolean ) {
155+ override fun onAppInForeground () {
154156 trace(
155157 tag = " Session" ,
156158 message = " onAppInForeground" ,
157159 type = TraceType .Process ,
158160 )
159161 startPolling()
160162 updateUserFlags()
161- if (checkForAirdrops) {
162- checkForAirdrops()
163- }
163+ checkForAirdrops()
164164 checkPendingItemsInFeed()
165165 bringActivityFeedCurrent()
166166 shareSheetController.checkForShare()
@@ -215,15 +215,16 @@ class RealSessionController @Inject constructor(
215215 }
216216 }
217217
218- private fun checkForAirdrops () {
218+ private fun checkForAirdrops (onAirdropReceived : ( LocalFiat ) -> Unit = {} ) {
219219 if (userManager.authState.canAccessAuthenticatedApis) {
220220 scope.launch {
221221 userManager.accountCluster?.let {
222222 transactionController.airdrop(
223223 type = AirdropType .WelcomeBonus ,
224224 destination = it.authority.keyPair
225225 ).onSuccess { amount ->
226- presentWelcomeBonus(amount)
226+ welcomeBonus = amount
227+ onAirdropReceived(amount)
227228 }
228229 }
229230 }
@@ -280,7 +281,14 @@ class RealSessionController @Inject constructor(
280281 }
281282
282283 override fun onCameraVisible () {
283- checkForAirdrops()
284+ if (welcomeBonus != null ) {
285+ presentWelcomeBonus(welcomeBonus!! )
286+ welcomeBonus = null
287+ } else {
288+ checkForAirdrops {
289+ presentWelcomeBonus(it)
290+ }
291+ }
284292 }
285293
286294 override fun onCameraScanning (scanning : Boolean ) {
0 commit comments