mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 20:09:27 +03:00
Fix app non responsive
This commit is contained in:
parent
aecdd475d8
commit
2ea6cdba6f
5 changed files with 45 additions and 28 deletions
1
changelog.d/8454.bugfix
Normal file
1
changelog.d/8454.bugfix
Normal file
|
@ -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 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.homeserver.HomeServerCapabilitiesService
|
||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
||||
|
@ -64,9 +66,10 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
|
|||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
private val clock: Clock,
|
||||
private val homeServerCapabilitiesService: HomeServerCapabilitiesService,
|
||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||
) : SetReadMarkersTask {
|
||||
|
||||
override suspend fun execute(params: SetReadMarkersTask.Params) {
|
||||
override suspend fun execute(params: SetReadMarkersTask.Params) = withContext(coroutineDispatchers.io) {
|
||||
val markers = mutableMapOf<String, String>()
|
||||
Timber.v("Execute set read marker with params: $params")
|
||||
val latestSyncedEventId = latestSyncedEventId(params.roomId)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package im.vector.app.core.session.clientinfo
|
||||
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -27,7 +28,9 @@ class DeleteUnusedClientInformationUseCase @Inject constructor(
|
|||
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).
|
||||
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 }
|
||||
activeSessionHolder
|
||||
.getSafeActiveSession()
|
||||
|
@ -40,3 +43,4 @@ class DeleteUnusedClientInformationUseCase @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,11 +322,10 @@ class RoomListViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun handleDeleteLocalRooms() {
|
||||
viewModelScope.launch(session.coroutineDispatchers.io) {
|
||||
val localRoomIds = session.roomService()
|
||||
.getRoomSummaries(roomSummaryQueryParams { roomId = QueryStringValue.Contains(RoomLocalEcho.PREFIX) })
|
||||
.map { it.roomId }
|
||||
|
||||
viewModelScope.launch {
|
||||
localRoomIds.forEach {
|
||||
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.utils.FirstThrottler
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
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.content.ContentUrlResolver
|
||||
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.
|
||||
*/
|
||||
fun setCurrentRoom(roomId: String?) {
|
||||
val dispatcher = currentSession?.coroutineDispatchers?.io ?: return
|
||||
val scope = currentSession?.coroutineScope ?: return
|
||||
scope.launch(dispatcher) {
|
||||
updateEvents {
|
||||
val hasChanged = roomId != currentRoomId
|
||||
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.
|
||||
* 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?) {
|
||||
val dispatcher = currentSession?.coroutineDispatchers?.io ?: return
|
||||
val scope = currentSession?.coroutineScope ?: return
|
||||
scope.launch(dispatcher) {
|
||||
updateEvents {
|
||||
val hasChanged = threadId != currentThreadId
|
||||
currentThreadId = threadId
|
||||
|
@ -145,6 +154,7 @@ class NotificationDrawerManager @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun notificationStyleChanged() {
|
||||
updateEvents {
|
||||
|
|
Loading…
Reference in a new issue