Browse Source

Improve logs.

pull/852/head
Benoit Marty 1 year ago
parent
commit
1627dbfd27
  1. 4
      appnav/src/main/kotlin/io/element/android/appnav/di/MatrixClientsHolder.kt
  2. 3
      libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/RoomSummaryDataSource.kt
  3. 2
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomListExtensions.kt

4
appnav/src/main/kotlin/io/element/android/appnav/di/MatrixClientsHolder.kt

@ -54,10 +54,12 @@ class MatrixClientsHolder @Inject constructor(private val authenticationService: @@ -54,10 +54,12 @@ class MatrixClientsHolder @Inject constructor(private val authenticationService:
@Suppress("UNCHECKED_CAST")
fun restore(state: SavedStateMap?) {
Timber.d("Restore state")
if (state == null || sessionIdsToMatrixClient.isNotEmpty()) return Unit.also {
Timber.w("Restore with non-empty map")
}
val sessionIds = state[SAVE_INSTANCE_KEY] as? Array<SessionId>
Timber.d("Restore matrix session keys = ${sessionIds?.map { it.value }}")
if (sessionIds.isNullOrEmpty()) return
// Not ideal but should only happens in case of process recreation. This ensure we restore all the active sessions before restoring the node graphs.
runBlocking {
@ -76,7 +78,7 @@ class MatrixClientsHolder @Inject constructor(private val authenticationService: @@ -76,7 +78,7 @@ class MatrixClientsHolder @Inject constructor(private val authenticationService:
fun save(state: MutableSavedStateMap) {
val sessionKeys = sessionIdsToMatrixClient.keys.toTypedArray()
Timber.d("Save matrix session keys = $sessionKeys")
Timber.d("Save matrix session keys = ${sessionKeys.map { it.value }}")
state[SAVE_INSTANCE_KEY] = sessionKeys
}
}

3
libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/RoomSummaryDataSource.kt

@ -38,12 +38,13 @@ interface RoomSummaryDataSource { @@ -38,12 +38,13 @@ interface RoomSummaryDataSource {
suspend fun RoomSummaryDataSource.awaitAllRoomsAreLoaded(timeout: Duration = Duration.INFINITE) {
try {
Timber.d("awaitAllRoomsAreLoaded: wait")
withTimeout(timeout) {
allRoomsLoadingState().firstOrNull {
it is RoomSummaryDataSource.LoadingState.Loaded
}
}
} catch (timeoutException: TimeoutCancellationException) {
Timber.v("AwaitAllRooms: no response after $timeout")
Timber.d("awaitAllRoomsAreLoaded: no response after $timeout")
}
}

2
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomListExtensions.kt

@ -62,7 +62,7 @@ fun RoomListService.roomOrNull(roomId: String): RoomListItem? { @@ -62,7 +62,7 @@ fun RoomListService.roomOrNull(roomId: String): RoomListItem? {
return try {
room(roomId)
} catch (exception: RoomListException) {
Timber.e(exception, "Failed finding room with id=$roomId")
Timber.d(exception, "Failed finding room with id=$roomId.")
return null
}
}

Loading…
Cancel
Save