mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Fix crash with incorrectly tagged story.
This commit is contained in:
committed by
Cody Henthorne
parent
78214fb39b
commit
6048208c8c
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user