From 4112d2812706ce10e0248a5dd555d7c4952c4f29 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 14 May 2021 14:56:31 +0200 Subject: [PATCH] Remove usage of GlobalScope --- .../vector/app/features/media/VideoContentRenderer.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/media/VideoContentRenderer.kt b/vector/src/main/java/im/vector/app/features/media/VideoContentRenderer.kt index 80d2d8ba45..635de2ba16 100644 --- a/vector/src/main/java/im/vector/app/features/media/VideoContentRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/media/VideoContentRenderer.kt @@ -25,8 +25,9 @@ import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.files.LocalFilesHelper +import im.vector.app.features.session.coroutineScope +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import kotlinx.parcelize.Parcelize @@ -39,6 +40,9 @@ class VideoContentRenderer @Inject constructor(private val localFilesHelper: Loc private val activeSessionHolder: ActiveSessionHolder, private val errorFormatter: ErrorFormatter) { + private val sessionScope: CoroutineScope + get() = activeSessionHolder.getActiveSession().coroutineScope + @Parcelize data class Data( override val eventId: String, @@ -76,7 +80,7 @@ class VideoContentRenderer @Inject constructor(private val localFilesHelper: Loc thumbnailView.isVisible = true loadingView.isVisible = true - GlobalScope.launch { + sessionScope.launch { val result = runCatching { activeSessionHolder.getActiveSession().fileService() .downloadFile( @@ -119,7 +123,7 @@ class VideoContentRenderer @Inject constructor(private val localFilesHelper: Loc thumbnailView.isVisible = true loadingView.isVisible = true - GlobalScope.launch { + sessionScope.launch { val result = runCatching { activeSessionHolder.getActiveSession().fileService() .downloadFile(