Add extra logs for timeline pagination (#6589)
We found some possible rare issues with pagination these could help understand.
This commit is contained in:
parent
66513bc905
commit
0058de9bca
1 changed files with 13 additions and 9 deletions
|
|
@ -130,6 +130,8 @@ class RustTimeline(
|
||||||
Timeline.PaginationStatus(isPaginating = false, hasMoreToLoad = mode is Timeline.Mode.FocusedOnEvent)
|
Timeline.PaginationStatus(isPaginating = false, hasMoreToLoad = mode is Timeline.Mode.FocusedOnEvent)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val loggerTag = "Timeline($mode)"
|
||||||
|
|
||||||
init {
|
init {
|
||||||
when (mode) {
|
when (mode) {
|
||||||
is Timeline.Mode.Live, is Timeline.Mode.FocusedOnEvent -> coroutineScope.fetchMembers()
|
is Timeline.Mode.Live, is Timeline.Mode.FocusedOnEvent -> coroutineScope.fetchMembers()
|
||||||
|
|
@ -177,10 +179,11 @@ class RustTimeline(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePaginationStatus(direction: Timeline.PaginationDirection, update: (Timeline.PaginationStatus) -> Timeline.PaginationStatus) {
|
private fun updatePaginationStatus(direction: Timeline.PaginationDirection, update: (Timeline.PaginationStatus) -> Timeline.PaginationStatus) {
|
||||||
when (direction) {
|
val result = when (direction) {
|
||||||
Timeline.PaginationDirection.BACKWARDS -> backwardPaginationStatus.getAndUpdate(update)
|
Timeline.PaginationDirection.BACKWARDS -> backwardPaginationStatus.getAndUpdate(update)
|
||||||
Timeline.PaginationDirection.FORWARDS -> forwardPaginationStatus.getAndUpdate(update)
|
Timeline.PaginationDirection.FORWARDS -> forwardPaginationStatus.getAndUpdate(update)
|
||||||
}
|
}
|
||||||
|
Timber.tag(loggerTag).d("updatePaginationStatus $direction: $result")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use NonCancellable to avoid breaking the timeline when the coroutine is cancelled.
|
// Use NonCancellable to avoid breaking the timeline when the coroutine is cancelled.
|
||||||
|
|
@ -195,12 +198,13 @@ class RustTimeline(
|
||||||
}
|
}
|
||||||
}.onFailure { error ->
|
}.onFailure { error ->
|
||||||
if (error is TimelineException.CannotPaginate) {
|
if (error is TimelineException.CannotPaginate) {
|
||||||
Timber.d("Can't paginate $direction on room ${joinedRoom.roomId} with paginationStatus: ${backwardPaginationStatus.value}")
|
Timber.tag(loggerTag).d("Can't paginate $direction on room ${joinedRoom.roomId} with paginationStatus: ${backwardPaginationStatus.value}")
|
||||||
} else {
|
} else {
|
||||||
updatePaginationStatus(direction) { it.copy(isPaginating = false) }
|
updatePaginationStatus(direction) { it.copy(isPaginating = false) }
|
||||||
Timber.e(error, "Error paginating $direction on room ${joinedRoom.roomId}")
|
Timber.tag(loggerTag).e(error, "Error paginating $direction on room ${joinedRoom.roomId}")
|
||||||
}
|
}
|
||||||
}.onSuccess { hasReachedEnd ->
|
}.onSuccess { hasReachedEnd ->
|
||||||
|
Timber.tag(loggerTag).d("Finished paginating $direction on room ${joinedRoom.roomId}, hasReachedEnd: $hasReachedEnd")
|
||||||
updatePaginationStatus(direction) { it.copy(isPaginating = false, hasMoreToLoad = !hasReachedEnd) }
|
updatePaginationStatus(direction) { it.copy(isPaginating = false, hasMoreToLoad = !hasReachedEnd) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +268,7 @@ class RustTimeline(
|
||||||
try {
|
try {
|
||||||
inner.fetchMembers()
|
inner.fetchMembers()
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Timber.e(exception, "Error fetching members for room ${joinedRoom.roomId}")
|
Timber.tag(loggerTag).e(exception, "Error fetching members for room ${joinedRoom.roomId}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,7 +374,7 @@ class RustTimeline(
|
||||||
formattedCaption: String?,
|
formattedCaption: String?,
|
||||||
inReplyToEventId: EventId?,
|
inReplyToEventId: EventId?,
|
||||||
): Result<MediaUploadHandler> {
|
): Result<MediaUploadHandler> {
|
||||||
Timber.d("Sending image ${file.path.hash()}")
|
Timber.tag(loggerTag).d("Sending image ${file.path.hash()}")
|
||||||
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
||||||
inner.sendImage(
|
inner.sendImage(
|
||||||
params = UploadParameters(
|
params = UploadParameters(
|
||||||
|
|
@ -396,7 +400,7 @@ class RustTimeline(
|
||||||
formattedCaption: String?,
|
formattedCaption: String?,
|
||||||
inReplyToEventId: EventId?,
|
inReplyToEventId: EventId?,
|
||||||
): Result<MediaUploadHandler> {
|
): Result<MediaUploadHandler> {
|
||||||
Timber.d("Sending video ${file.path.hash()}")
|
Timber.tag(loggerTag).d("Sending video ${file.path.hash()}")
|
||||||
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
||||||
inner.sendVideo(
|
inner.sendVideo(
|
||||||
params = UploadParameters(
|
params = UploadParameters(
|
||||||
|
|
@ -421,7 +425,7 @@ class RustTimeline(
|
||||||
formattedCaption: String?,
|
formattedCaption: String?,
|
||||||
inReplyToEventId: EventId?,
|
inReplyToEventId: EventId?,
|
||||||
): Result<MediaUploadHandler> {
|
): Result<MediaUploadHandler> {
|
||||||
Timber.d("Sending audio ${file.path.hash()}")
|
Timber.tag(loggerTag).d("Sending audio ${file.path.hash()}")
|
||||||
return sendAttachment(listOf(file)) {
|
return sendAttachment(listOf(file)) {
|
||||||
inner.sendAudio(
|
inner.sendAudio(
|
||||||
params = UploadParameters(
|
params = UploadParameters(
|
||||||
|
|
@ -445,7 +449,7 @@ class RustTimeline(
|
||||||
formattedCaption: String?,
|
formattedCaption: String?,
|
||||||
inReplyToEventId: EventId?,
|
inReplyToEventId: EventId?,
|
||||||
): Result<MediaUploadHandler> {
|
): Result<MediaUploadHandler> {
|
||||||
Timber.d("Sending file ${file.path.hash()}")
|
Timber.tag(loggerTag).d("Sending file ${file.path.hash()}")
|
||||||
return sendAttachment(listOf(file)) {
|
return sendAttachment(listOf(file)) {
|
||||||
inner.sendFile(
|
inner.sendFile(
|
||||||
params = UploadParameters(
|
params = UploadParameters(
|
||||||
|
|
@ -475,7 +479,7 @@ class RustTimeline(
|
||||||
runCatchingExceptions {
|
runCatchingExceptions {
|
||||||
roomContentForwarder.forward(fromTimeline = inner, eventId = eventId, toRoomIds = roomIds)
|
roomContentForwarder.forward(fromTimeline = inner, eventId = eventId, toRoomIds = roomIds)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
Timber.e(it)
|
Timber.tag(loggerTag).e(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue