From 31d774aabb0fd58c5d9635e063702343e0bbc8d2 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Fri, 28 Jul 2023 15:09:38 +1000 Subject: [PATCH] refactor: use global scope to avoid lifecycleScope cancelling before we open the picker intent --- .../thoughtcrime/securesms/preferences/ShareLogsDialog.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt index f8aa0e375..e671a121a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt @@ -13,8 +13,9 @@ import android.provider.MediaStore import android.webkit.MimeTypeMap import android.widget.Toast import androidx.fragment.app.DialogFragment -import androidx.lifecycle.lifecycleScope +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import network.loki.messenger.BuildConfig @@ -42,11 +43,12 @@ class ShareLogsDialog : DialogFragment() { cancelButton { dismiss() } } + @OptIn(DelicateCoroutinesApi::class) private fun shareLogs() { val persistentLogger = ApplicationContext.getInstance(context).persistentLogger - lifecycleScope.launch(Dispatchers.Main) { + val context = requireContext().applicationContext + GlobalScope.launch(Dispatchers.Main) { try { - val context = requireContext() val outputUri: Uri = withContext(Dispatchers.IO) { ExternalStorageUtil.getDownloadUri() } val mediaUri = withContext(Dispatchers.IO) { getExternalFile() } if (mediaUri == null) {