Don't blindly retry fetching pending or failed event details
This commit is contained in:
parent
babb25d45f
commit
f7f6fdc770
3 changed files with 17 additions and 2 deletions
|
|
@ -35,7 +35,13 @@ data class MessageContent(
|
||||||
|
|
||||||
|
|
||||||
sealed interface InReplyTo {
|
sealed interface InReplyTo {
|
||||||
|
/** The event details are not loaded yet. We can fetch them. */
|
||||||
data class NotLoaded(val eventId: EventId) : InReplyTo
|
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(
|
data class Ready(
|
||||||
val eventId: EventId,
|
val eventId: EventId,
|
||||||
val content: MessageContent,
|
val content: MessageContent,
|
||||||
|
|
@ -44,6 +50,14 @@ sealed interface InReplyTo {
|
||||||
val senderAvatarUrl: String?,
|
val senderAvatarUrl: String?,
|
||||||
) : InReplyTo
|
) : 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
|
object Error : InReplyTo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,6 @@ data class EventTimelineItem(
|
||||||
}
|
}
|
||||||
fun hasNotLoadedInReplyTo(): Boolean {
|
fun hasNotLoadedInReplyTo(): Boolean {
|
||||||
val details = inReplyTo()
|
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.Error -> InReplyTo.Error
|
||||||
is RepliedToEventDetails.Pending, is RepliedToEventDetails.Unavailable -> InReplyTo.NotLoaded(inReplyToId!!)
|
is RepliedToEventDetails.Pending -> InReplyTo.Pending
|
||||||
|
is RepliedToEventDetails.Unavailable -> InReplyTo.NotLoaded(inReplyToId!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageContent(
|
MessageContent(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue