Skip to content

Commit 243a39d

Browse files
committed
Don't blindly retry fetching pending or failed event details
1 parent 9bf388e commit 243a39d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/EventContent.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ data class MessageContent(
3535

3636

3737
sealed interface InReplyTo {
38+
/** The event details are not loaded yet. We can fetch them. */
3839
data class NotLoaded(val eventId: EventId) : InReplyTo
40+
41+
/** The event details are pending to be fetched. We should **not** fetch them again. */
42+
object Pending : InReplyTo
43+
44+
/** The event details are available. */
3945
data class Ready(
4046
val eventId: EventId,
4147
val content: MessageContent,
@@ -44,6 +50,14 @@ sealed interface InReplyTo {
4450
val senderAvatarUrl: String?,
4551
) : InReplyTo
4652

53+
/**
54+
* Fetching the event details failed.
55+
*
56+
* We can try to fetch them again **with a proper retry strategy**, but not blindly:
57+
*
58+
* If the reason for the failure is consistent on the server, we'd enter a loop
59+
* where we keep trying to fetch the same event.
60+
* */
4761
object Error : InReplyTo
4862
}
4963

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/EventTimelineItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ data class EventTimelineItem(
4242
}
4343
fun hasNotLoadedInReplyTo(): Boolean {
4444
val details = inReplyTo()
45-
return details is InReplyTo.NotLoaded || details is InReplyTo.Error
45+
return details is InReplyTo.NotLoaded
4646
}
4747
}

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class EventMessageMapper {
5858
)
5959
}
6060
is RepliedToEventDetails.Error -> InReplyTo.Error
61-
is RepliedToEventDetails.Pending, is RepliedToEventDetails.Unavailable -> InReplyTo.NotLoaded(inReplyToId!!)
61+
is RepliedToEventDetails.Pending -> InReplyTo.Pending
62+
is RepliedToEventDetails.Unavailable -> InReplyTo.NotLoaded(inReplyToId!!)
6263
}
6364
}
6465
MessageContent(

0 commit comments

Comments
 (0)