mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Avoid hardcoded dispatchers.
Fix issue detected by sonar.
This commit is contained in:
+3
-1
@@ -20,6 +20,7 @@ import android.content.Context
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import io.element.android.libraries.androidutils.file.safeDelete
|
import io.element.android.libraries.androidutils.file.safeDelete
|
||||||
import io.element.android.libraries.core.data.tryOrNull
|
import io.element.android.libraries.core.data.tryOrNull
|
||||||
|
import kotlinx.coroutines.CoroutineDispatcher
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@@ -38,6 +39,7 @@ import java.util.logging.Logger
|
|||||||
class VectorFileLogger(
|
class VectorFileLogger(
|
||||||
context: Context,
|
context: Context,
|
||||||
// private val vectorPreferences: VectorPreferences
|
// private val vectorPreferences: VectorPreferences
|
||||||
|
private val dispatcher: CoroutineDispatcher = Dispatchers.IO,
|
||||||
) : Timber.Tree() {
|
) : Timber.Tree() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -109,7 +111,7 @@ class VectorFileLogger(
|
|||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||||
fileHandler ?: return
|
fileHandler ?: return
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(dispatcher) {
|
||||||
if (skipLog(priority)) return@launch
|
if (skipLog(priority)) return@launch
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
logToFile(t)
|
logToFile(t)
|
||||||
|
|||||||
+4
-3
@@ -24,11 +24,11 @@ import io.element.android.features.rageshake.logs.VectorFileLogger
|
|||||||
import io.element.android.features.rageshake.screenshot.ScreenshotHolder
|
import io.element.android.features.rageshake.screenshot.ScreenshotHolder
|
||||||
import io.element.android.libraries.androidutils.file.compressFile
|
import io.element.android.libraries.androidutils.file.compressFile
|
||||||
import io.element.android.libraries.androidutils.file.safeDelete
|
import io.element.android.libraries.androidutils.file.safeDelete
|
||||||
|
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||||
import io.element.android.libraries.core.extensions.toOnOff
|
import io.element.android.libraries.core.extensions.toOnOff
|
||||||
import io.element.android.libraries.core.mimetype.MimeTypes
|
import io.element.android.libraries.core.mimetype.MimeTypes
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
import io.element.android.libraries.di.ApplicationContext
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -55,6 +55,7 @@ class BugReporter @Inject constructor(
|
|||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val screenshotHolder: ScreenshotHolder,
|
private val screenshotHolder: ScreenshotHolder,
|
||||||
private val crashDataStore: CrashDataStore,
|
private val crashDataStore: CrashDataStore,
|
||||||
|
private val coroutineDispatchers: CoroutineDispatchers,
|
||||||
/*
|
/*
|
||||||
private val activeSessionHolder: ActiveSessionHolder,
|
private val activeSessionHolder: ActiveSessionHolder,
|
||||||
private val versionProvider: VersionProvider,
|
private val versionProvider: VersionProvider,
|
||||||
@@ -169,7 +170,7 @@ class BugReporter @Inject constructor(
|
|||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
var serverError: String? = null
|
var serverError: String? = null
|
||||||
var reportURL: String? = null
|
var reportURL: String? = null
|
||||||
withContext(Dispatchers.IO) {
|
withContext(coroutineDispatchers.io) {
|
||||||
var bugDescription = theBugDescription
|
var bugDescription = theBugDescription
|
||||||
val crashCallStack = crashDataStore.crashInfo().first()
|
val crashCallStack = crashDataStore.crashInfo().first()
|
||||||
|
|
||||||
@@ -419,7 +420,7 @@ class BugReporter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(coroutineDispatchers.main) {
|
||||||
mBugReportCall = null
|
mBugReportCall = null
|
||||||
|
|
||||||
// delete when the bug report has been successfully sent
|
// delete when the bug report has been successfully sent
|
||||||
|
|||||||
Reference in New Issue
Block a user