Skip to content

Commit

Permalink
fix (explore-dash): propagate getValue crashes to the sync worker to …
Browse files Browse the repository at this point in the history
…be logged as non-fatal (#870)

* chore: bumping version
  • Loading branch information
Syn-McJ authored Jan 13, 2022
1 parent 79fc7b4 commit 51c6780
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.google.firebase.database.ktx.database
import com.google.firebase.database.ktx.getValue
import com.google.firebase.ktx.Firebase
import kotlinx.coroutines.suspendCancellableCoroutine
import java.lang.Exception
import javax.inject.Inject
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
Expand Down Expand Up @@ -69,13 +70,20 @@ class FirebaseExploreDatabase @Inject constructor() : ExploreRepository {
query.addListenerForSingleValueEvent(object: ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val data = mutableListOf<T>()
dataSnapshot.children.forEach {
val merchant = it.getValue(valueType)!!
data.add(merchant)
}

if (coroutine.isActive) {
coroutine.resume(data)
try {
dataSnapshot.children.forEach {
val merchant = it.getValue(valueType)!!
data.add(merchant)
}

if (coroutine.isActive) {
coroutine.resume(data)
}
} catch (ex: Exception) {
if (coroutine.isActive) {
coroutine.resumeWithException(ex)
}
}
}

Expand All @@ -96,7 +104,11 @@ class FirebaseExploreDatabase @Inject constructor() : ExploreRepository {
query.addListenerForSingleValueEvent(object: ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
if (coroutine.isActive) {
coroutine.resume(dataSnapshot.getValue<Int>()!!)
try {
coroutine.resume(dataSnapshot.getValue<Int>()!!)
} catch (ex: Exception) {
coroutine.resumeWithException(ex)
}
}
}

Expand All @@ -117,7 +129,11 @@ class FirebaseExploreDatabase @Inject constructor() : ExploreRepository {
query.addListenerForSingleValueEvent(object: ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
if (coroutine.isActive) {
coroutine.resume(dataSnapshot.getValue<Long>()!!)
try {
coroutine.resume(dataSnapshot.getValue<Long>()!!)
} catch (ex: Exception) {
coroutine.resumeWithException(ex)
}
}
}

Expand All @@ -138,7 +154,11 @@ class FirebaseExploreDatabase @Inject constructor() : ExploreRepository {
query.addListenerForSingleValueEvent(object: ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
if (coroutine.isActive) {
coroutine.resume(dataSnapshot.getValue<Long>()!!)
try {
coroutine.resume(dataSnapshot.getValue<Long>()!!)
} catch (ex: Exception) {
coroutine.resumeWithException(ex)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ android {
defaultConfig {
minSdkVersion 23
targetSdkVersion 30
versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 70412
versionName project.hasProperty('versionName') ? project.property('versionName') : "7.4.1"
versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 70420
versionName project.hasProperty('versionName') ? project.property('versionName') : "7.4.2"
multiDexEnabled true
generatedDensities = ['hdpi', 'xhdpi']
vectorDrawables.useSupportLibrary = true
Expand Down

0 comments on commit 51c6780

Please sign in to comment.