Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion android/src/main/java/com/expensify/wallet/WalletModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.google.android.gms.tapandpay.issuer.PushTokenizeRequest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import com.expensify.wallet.Utils.getAsyncResult
import com.expensify.wallet.Utils.toCardData
import com.expensify.wallet.error.InvalidNetworkError
Expand Down Expand Up @@ -50,6 +52,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
private val tapAndPayClient: TapAndPayClient = TapAndPay.getClient(activity)
private var pendingCreateWalletPromise: Promise? = null
private var pendingPushTokenizePromise: Promise? = null
private val moduleScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

override fun initialize() {
super.initialize()
Expand All @@ -58,6 +61,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :

override fun invalidate() {
super.invalidate()
moduleScope.cancel()
reactApplicationContext.removeActivityEventListener(cardListener)
}

Expand Down Expand Up @@ -119,7 +123,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :

@ReactMethod
override fun getSecureWalletInfo(promise: Promise) {
CoroutineScope(Dispatchers.Main).launch {
moduleScope.launch {
try {
val walletId = getWalletIdAsync()
val hardwareId = getHardwareIdAsync()
Expand Down