Add better error handling for empty story text post.

This commit is contained in:
Alex Hart 2024-09-27 10:38:59 -03:00
parent 5212088a1b
commit ea33fa2af1

View file

@ -83,7 +83,13 @@ class StoryPostViewModel(private val repository: StoryTextPostRepository) : View
val text: StoryTextPost = if (record.body.isNotEmpty()) {
StoryTextPost.ADAPTER.decode(Base64.decode(record.body))
} else {
throw Exception("Text post message body is empty.")
Log.w(TAG, "Failed to decode empty story text post body.")
store.update {
StoryPostState.TextPost(
loadState = StoryPostState.LoadState.FAILED
)
}
return@subscribeBy
}
val linkPreview = record.linkPreviews.firstOrNull()