Fix crash with incorrectly tagged story.

This commit is contained in:
Alex Hart
2022-03-09 14:04:07 -04:00
committed by Cody Henthorne
parent 78214fb39b
commit 6048208c8c
2 changed files with 22 additions and 18 deletions

View File

@@ -172,7 +172,7 @@ class StoryViewerPageRepository(context: Context) {
}
private fun getContent(record: MmsMessageRecord): StoryPost.Content {
return if (record.storyType.isTextStory) {
return if (record.storyType.isTextStory || record.slideDeck.asAttachments().isEmpty()) {
StoryPost.Content.TextContent(
uri = Uri.parse("story_text_post://${record.id}"),
recordId = record.id

View File

@@ -18,24 +18,28 @@ class StoryTextPostViewModel(recordId: Long, repository: StoryTextPostRepository
val state: LiveData<StoryTextPostState> = store.stateLiveData
init {
disposables += repository.getRecord(recordId).subscribeBy(
onSuccess = { record ->
store.update { state ->
state.copy(
storyTextPost = StoryTextPost.parseFrom(Base64.decode(record.body)),
linkPreview = record.linkPreviews.firstOrNull(),
loadState = StoryTextPostState.LoadState.LOADED
)
}
},
onError = {
store.update { state ->
state.copy(
loadState = StoryTextPostState.LoadState.FAILED
)
}
disposables += repository.getRecord(recordId)
.map { record ->
StoryTextPost.parseFrom(Base64.decode(record.body)) to record.linkPreviews.firstOrNull()
}
)
.subscribeBy(
onSuccess = { (post, previews) ->
store.update { state ->
state.copy(
storyTextPost = post,
linkPreview = previews,
loadState = StoryTextPostState.LoadState.LOADED
)
}
},
onError = {
store.update { state ->
state.copy(
loadState = StoryTextPostState.LoadState.FAILED
)
}
}
)
}
override fun onCleared() {