GlobalScope -> sessionScope

This commit is contained in:
Benoit Marty 2021-04-19 11:36:54 +02:00 committed by Benoit Marty
parent 82ee2567b7
commit 8afa697591
3 changed files with 5 additions and 7 deletions

View file

@ -115,7 +115,7 @@ class VectorGlideDataFetcher(context: Context,
callback.onLoadFailed(IllegalArgumentException("No File service"))
}
// Use the file vector service, will avoid flickering and redownload after upload
GlobalScope.launch {
activeSessionHolder.getSafeActiveSession()?.launch {
val result = runCatching {
fileService.downloadFile(
fileName = data.filename,

View file

@ -1749,7 +1749,7 @@ class RoomDetailFragment @Inject constructor(
sharedActionViewModel.pendingAction = action
return
}
lifecycleScope.launch {
session.launch {
val result = runCatching { session.fileService().downloadFile(messageContent = action.messageContent) }
if (!isAdded) return@launch
result.fold(

View file

@ -23,8 +23,6 @@ import androidx.core.app.RemoteInput
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.extensions.vectorComponent
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.room.Room
@ -78,7 +76,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
activeSessionHolder.getSafeActiveSession()?.let { session ->
val room = session.getRoom(roomId)
if (room != null) {
GlobalScope.launch {
session.launch {
tryOrNull { room.join() }
}
}
@ -89,7 +87,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
activeSessionHolder.getSafeActiveSession()?.let { session ->
val room = session.getRoom(roomId)
if (room != null) {
GlobalScope.launch {
session.launch {
tryOrNull { room.leave() }
}
}
@ -100,7 +98,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
activeSessionHolder.getActiveSession().let { session ->
val room = session.getRoom(roomId)
if (room != null) {
GlobalScope.launch {
session.launch {
tryOrNull { room.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT) }
}
}