Fix app non responsive
This commit is contained in:
parent
aecdd475d8
commit
2ea6cdba6f
|
@ -0,0 +1 @@
|
||||||
|
Fix several performance issues causing app non responsive issues.
|
|
@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.session.room.read
|
||||||
|
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.api.session.events.model.LocalEcho
|
import org.matrix.android.sdk.api.session.events.model.LocalEcho
|
||||||
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
|
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
||||||
|
@ -64,9 +66,10 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||||
private val clock: Clock,
|
private val clock: Clock,
|
||||||
private val homeServerCapabilitiesService: HomeServerCapabilitiesService,
|
private val homeServerCapabilitiesService: HomeServerCapabilitiesService,
|
||||||
|
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||||
) : SetReadMarkersTask {
|
) : SetReadMarkersTask {
|
||||||
|
|
||||||
override suspend fun execute(params: SetReadMarkersTask.Params) {
|
override suspend fun execute(params: SetReadMarkersTask.Params) = withContext(coroutineDispatchers.io) {
|
||||||
val markers = mutableMapOf<String, String>()
|
val markers = mutableMapOf<String, String>()
|
||||||
Timber.v("Execute set read marker with params: $params")
|
Timber.v("Execute set read marker with params: $params")
|
||||||
val latestSyncedEventId = latestSyncedEventId(params.roomId)
|
val latestSyncedEventId = latestSyncedEventId(params.roomId)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.app.core.session.clientinfo
|
package im.vector.app.core.session.clientinfo
|
||||||
|
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -27,7 +28,9 @@ class DeleteUnusedClientInformationUseCase @Inject constructor(
|
||||||
suspend fun execute(deviceInfoList: List<DeviceInfo>): Result<Unit> = runCatching {
|
suspend fun execute(deviceInfoList: List<DeviceInfo>): Result<Unit> = runCatching {
|
||||||
// A defensive approach against local storage reports an empty device list (although it is not a seen situation).
|
// A defensive approach against local storage reports an empty device list (although it is not a seen situation).
|
||||||
if (deviceInfoList.isEmpty()) return Result.success(Unit)
|
if (deviceInfoList.isEmpty()) return Result.success(Unit)
|
||||||
|
val dispatcher = activeSessionHolder.getSafeActiveSession()?.coroutineDispatchers?.io
|
||||||
|
?: return@runCatching
|
||||||
|
withContext(dispatcher) {
|
||||||
val expectedClientInfoKeyList = deviceInfoList.map { MATRIX_CLIENT_INFO_KEY_PREFIX + it.deviceId }
|
val expectedClientInfoKeyList = deviceInfoList.map { MATRIX_CLIENT_INFO_KEY_PREFIX + it.deviceId }
|
||||||
activeSessionHolder
|
activeSessionHolder
|
||||||
.getSafeActiveSession()
|
.getSafeActiveSession()
|
||||||
|
@ -39,4 +42,5 @@ class DeleteUnusedClientInformationUseCase @Inject constructor(
|
||||||
activeSessionHolder.getSafeActiveSession()?.accountDataService()?.deleteUserAccountData(userAccountDataKeyToDelete)
|
activeSessionHolder.getSafeActiveSession()?.accountDataService()?.deleteUserAccountData(userAccountDataKeyToDelete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,11 +322,10 @@ class RoomListViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDeleteLocalRooms() {
|
private fun handleDeleteLocalRooms() {
|
||||||
|
viewModelScope.launch(session.coroutineDispatchers.io) {
|
||||||
val localRoomIds = session.roomService()
|
val localRoomIds = session.roomService()
|
||||||
.getRoomSummaries(roomSummaryQueryParams { roomId = QueryStringValue.Contains(RoomLocalEcho.PREFIX) })
|
.getRoomSummaries(roomSummaryQueryParams { roomId = QueryStringValue.Contains(RoomLocalEcho.PREFIX) })
|
||||||
.map { it.roomId }
|
.map { it.roomId }
|
||||||
|
|
||||||
viewModelScope.launch {
|
|
||||||
localRoomIds.forEach {
|
localRoomIds.forEach {
|
||||||
session.roomService().deleteLocalRoom(it)
|
session.roomService().deleteLocalRoom(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ import im.vector.app.R
|
||||||
import im.vector.app.core.resources.BuildMeta
|
import im.vector.app.core.resources.BuildMeta
|
||||||
import im.vector.app.core.utils.FirstThrottler
|
import im.vector.app.core.utils.FirstThrottler
|
||||||
import im.vector.app.features.displayname.getBestName
|
import im.vector.app.features.displayname.getBestName
|
||||||
|
import im.vector.app.features.session.coroutineScope
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
||||||
import org.matrix.android.sdk.api.session.getUserOrDefault
|
import org.matrix.android.sdk.api.session.getUserOrDefault
|
||||||
|
@ -121,6 +123,9 @@ class NotificationDrawerManager @Inject constructor(
|
||||||
* Used to ignore events related to that room (no need to display notification) and clean any existing notification on this room.
|
* Used to ignore events related to that room (no need to display notification) and clean any existing notification on this room.
|
||||||
*/
|
*/
|
||||||
fun setCurrentRoom(roomId: String?) {
|
fun setCurrentRoom(roomId: String?) {
|
||||||
|
val dispatcher = currentSession?.coroutineDispatchers?.io ?: return
|
||||||
|
val scope = currentSession?.coroutineScope ?: return
|
||||||
|
scope.launch(dispatcher) {
|
||||||
updateEvents {
|
updateEvents {
|
||||||
val hasChanged = roomId != currentRoomId
|
val hasChanged = roomId != currentRoomId
|
||||||
currentRoomId = roomId
|
currentRoomId = roomId
|
||||||
|
@ -129,12 +134,16 @@ class NotificationDrawerManager @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called when the application is currently opened and showing timeline for the given threadId.
|
* Should be called when the application is currently opened and showing timeline for the given threadId.
|
||||||
* Used to ignore events related to that thread (no need to display notification) and clean any existing notification on this room.
|
* Used to ignore events related to that thread (no need to display notification) and clean any existing notification on this room.
|
||||||
*/
|
*/
|
||||||
fun setCurrentThread(threadId: String?) {
|
fun setCurrentThread(threadId: String?) {
|
||||||
|
val dispatcher = currentSession?.coroutineDispatchers?.io ?: return
|
||||||
|
val scope = currentSession?.coroutineScope ?: return
|
||||||
|
scope.launch(dispatcher) {
|
||||||
updateEvents {
|
updateEvents {
|
||||||
val hasChanged = threadId != currentThreadId
|
val hasChanged = threadId != currentThreadId
|
||||||
currentThreadId = threadId
|
currentThreadId = threadId
|
||||||
|
@ -145,6 +154,7 @@ class NotificationDrawerManager @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun notificationStyleChanged() {
|
fun notificationStyleChanged() {
|
||||||
updateEvents {
|
updateEvents {
|
||||||
|
|
Loading…
Reference in New Issue