kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix voice note crash when future failed.
rodzic
a835e5d143
commit
73e46053f0
|
@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
|||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
import java.util.concurrent.ExecutionException
|
||||
|
||||
/**
|
||||
* ViewModel responsible for holding Voice Note draft state. The intention is to allow
|
||||
|
@ -46,8 +47,20 @@ class DraftViewModel @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun saveEphemeralVoiceNoteDraft(voiceNoteDraftFuture: ListenableFuture<VoiceNoteDraft>) {
|
||||
store.update {
|
||||
saveDrafts(it.copy(voiceNoteDraft = voiceNoteDraftFuture.get().asDraft()))
|
||||
store.update { draftState ->
|
||||
val draft: VoiceNoteDraft? = try {
|
||||
voiceNoteDraftFuture.get()
|
||||
} catch (e: ExecutionException) {
|
||||
null
|
||||
} catch (e: InterruptedException) {
|
||||
null
|
||||
}
|
||||
|
||||
if (draft != null) {
|
||||
saveDrafts(draftState.copy(voiceNoteDraft = draft.asDraft()))
|
||||
} else {
|
||||
draftState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue