diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index e89a060022..a3d8f39b30 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -137,6 +137,6 @@ object VectorStaticModule { @Provides @JvmStatic fun providesCoroutineDispatchers(): CoroutineDispatchers { - return CoroutineDispatchers(io = Dispatchers.IO) + return CoroutineDispatchers(io = Dispatchers.IO, computation = Dispatchers.Default) } } diff --git a/vector/src/main/java/im/vector/app/core/dispatchers/CoroutineDispatchers.kt b/vector/src/main/java/im/vector/app/core/dispatchers/CoroutineDispatchers.kt index c489290a55..008ca4a9ce 100644 --- a/vector/src/main/java/im/vector/app/core/dispatchers/CoroutineDispatchers.kt +++ b/vector/src/main/java/im/vector/app/core/dispatchers/CoroutineDispatchers.kt @@ -19,4 +19,6 @@ package im.vector.app.core.dispatchers import kotlinx.coroutines.CoroutineDispatcher import javax.inject.Inject -data class CoroutineDispatchers @Inject constructor(val io: CoroutineDispatcher) +data class CoroutineDispatchers @Inject constructor( + val io: CoroutineDispatcher, + val computation: CoroutineDispatcher) diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt index ff553577a0..f1f5bf6adf 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt @@ -23,8 +23,11 @@ import androidx.core.content.getSystemService import androidx.core.content.pm.ShortcutManagerCompat import androidx.lifecycle.asFlow import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.core.dispatchers.CoroutineDispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.matrix.android.sdk.api.session.room.RoomSortOrder @@ -34,6 +37,7 @@ import javax.inject.Inject class ShortcutsHandler @Inject constructor( private val context: Context, + private val appDispatchers: CoroutineDispatchers, private val shortcutCreator: ShortcutCreator, private val activeSessionHolder: ActiveSessionHolder ) { @@ -67,6 +71,7 @@ class ShortcutsHandler @Inject constructor( ShortcutManagerCompat.pushDynamicShortcut(context, shortcut) } } + ?.flowOn(appDispatchers.computation) ?.launchIn(coroutineScope) ?: Job() } diff --git a/vector/src/test/java/im/vector/app/features/crypto/keys/KeysExporterTest.kt b/vector/src/test/java/im/vector/app/features/crypto/keys/KeysExporterTest.kt index c75abf5db4..57ad2a52ab 100644 --- a/vector/src/test/java/im/vector/app/features/crypto/keys/KeysExporterTest.kt +++ b/vector/src/test/java/im/vector/app/features/crypto/keys/KeysExporterTest.kt @@ -42,7 +42,7 @@ class KeysExporterTest { private val keysExporter = KeysExporter( session = FakeSession(fakeCryptoService = cryptoService), context = context.instance, - dispatchers = CoroutineDispatchers(Dispatchers.Unconfined) + dispatchers = CoroutineDispatchers(Dispatchers.Unconfined, Dispatchers.Unconfined) ) @Before