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")) callback.onLoadFailed(IllegalArgumentException("No File service"))
} }
// Use the file vector service, will avoid flickering and redownload after upload // Use the file vector service, will avoid flickering and redownload after upload
GlobalScope.launch { activeSessionHolder.getSafeActiveSession()?.launch {
val result = runCatching { val result = runCatching {
fileService.downloadFile( fileService.downloadFile(
fileName = data.filename, fileName = data.filename,

View File

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

View File

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