Don't blindly retry fetching pending or failed event details
This commit is contained in:
@@ -35,7 +35,13 @@ data class MessageContent(
|
||||
|
||||
|
||||
sealed interface InReplyTo {
|
||||
/** The event details are not loaded yet. We can fetch them. */
|
||||
data class NotLoaded(val eventId: EventId) : InReplyTo
|
||||
|
||||
/** The event details are pending to be fetched. We should **not** fetch them again. */
|
||||
object Pending : InReplyTo
|
||||
|
||||
/** The event details are available. */
|
||||
data class Ready(
|
||||
val eventId: EventId,
|
||||
val content: MessageContent,
|
||||
@@ -44,6 +50,14 @@ sealed interface InReplyTo {
|
||||
val senderAvatarUrl: String?,
|
||||
) : InReplyTo
|
||||
|
||||
/**
|
||||
* Fetching the event details failed.
|
||||
*
|
||||
* We can try to fetch them again **with a proper retry strategy**, but not blindly:
|
||||
*
|
||||
* If the reason for the failure is consistent on the server, we'd enter a loop
|
||||
* where we keep trying to fetch the same event.
|
||||
* */
|
||||
object Error : InReplyTo
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,6 @@ data class EventTimelineItem(
|
||||
}
|
||||
fun hasNotLoadedInReplyTo(): Boolean {
|
||||
val details = inReplyTo()
|
||||
return details is InReplyTo.NotLoaded || details is InReplyTo.Error
|
||||
return details is InReplyTo.NotLoaded
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ class EventMessageMapper {
|
||||
)
|
||||
}
|
||||
is RepliedToEventDetails.Error -> InReplyTo.Error
|
||||
is RepliedToEventDetails.Pending, is RepliedToEventDetails.Unavailable -> InReplyTo.NotLoaded(inReplyToId!!)
|
||||
is RepliedToEventDetails.Pending -> InReplyTo.Pending
|
||||
is RepliedToEventDetails.Unavailable -> InReplyTo.NotLoaded(inReplyToId!!)
|
||||
}
|
||||
}
|
||||
MessageContent(
|
||||
|
||||
Reference in New Issue
Block a user