Skip to content

Commit a9f0823

Browse files
committed
fix(session): utilize a supervisorJob to prevent all child jobs from being cancelled if one fails
This affected probably n number of things when this was recently converted away from a ViewModel into a standalone Singleton to support SessionController (previously HomeViewModel) usage outside of just the camera screen (e.g chat). The scoping that existed in it, however, didn't associate a supervisor Job so a generic one was established. This had the adverse affects of cancelling any and all running job's within the scope if one inadvertently failed for any reason. This impacted cash link receiving as a byproduct. Setup a supervisor job, on the IO thread, to alleviate the issue and allow child jobs to fail independently as expected. Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 40461c1 commit a9f0823

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/src/main/java/com/getcode/SessionController.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import io.reactivex.rxjava3.core.Completable
104104
import io.reactivex.rxjava3.schedulers.Schedulers
105105
import kotlinx.coroutines.CoroutineScope
106106
import kotlinx.coroutines.Dispatchers
107+
import kotlinx.coroutines.Job
107108
import kotlinx.coroutines.delay
108109
import kotlinx.coroutines.flow.MutableSharedFlow
109110
import kotlinx.coroutines.flow.MutableStateFlow
@@ -214,7 +215,8 @@ class SessionController @Inject constructor(
214215
betaFlagsRepository: BetaFlagsRepository,
215216
features: FeatureRepository,
216217
) {
217-
private val scope = CoroutineScope(Dispatchers.IO)
218+
private val supervisor = Job() + Dispatchers.IO
219+
private val scope = CoroutineScope(supervisor)
218220

219221
val state = MutableStateFlow(SessionState())
220222

0 commit comments

Comments
 (0)