Track errors in VoiceMessagePresenter (#1667)
Story: https://github.com/vector-im/element-meta/issues/2085
This commit is contained in:
parent
473ac2dcc1
commit
b137e1f1ab
3 changed files with 28 additions and 1 deletions
|
|
@ -23,4 +23,7 @@ internal sealed class VoiceMessageException : Exception() {
|
|||
data class PermissionMissing(
|
||||
override val message: String?, override val cause: Throwable?
|
||||
) : VoiceMessageException()
|
||||
data class PlayMessageError(
|
||||
override val message: String?, override val cause: Throwable?
|
||||
) : VoiceMessageException()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,13 @@ import dagger.multibindings.IntoMap
|
|||
import io.element.android.features.messages.impl.timeline.di.TimelineItemEventContentKey
|
||||
import io.element.android.features.messages.impl.timeline.di.TimelineItemPresenterFactory
|
||||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemVoiceContent
|
||||
import io.element.android.features.messages.impl.voicemessages.VoiceMessageException
|
||||
import io.element.android.libraries.architecture.Async
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.architecture.runUpdatingState
|
||||
import io.element.android.libraries.di.RoomScope
|
||||
import io.element.android.libraries.ui.utils.time.formatShort
|
||||
import io.element.android.services.analytics.api.AnalyticsService
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
|
|
@ -52,6 +54,7 @@ interface VoiceMessagePresenterModule {
|
|||
|
||||
class VoiceMessagePresenter @AssistedInject constructor(
|
||||
voiceMessagePlayerFactory: VoiceMessagePlayer.Factory,
|
||||
private val analyticsService: AnalyticsService,
|
||||
@Assisted private val content: TimelineItemVoiceContent,
|
||||
) : Presenter<VoiceMessageState> {
|
||||
|
||||
|
|
@ -102,7 +105,18 @@ class VoiceMessagePresenter @AssistedInject constructor(
|
|||
if (playerState.isPlaying) {
|
||||
player.pause()
|
||||
} else {
|
||||
scope.launch { play.runUpdatingState { player.play() } }
|
||||
scope.launch {
|
||||
play.runUpdatingState(
|
||||
errorTransform = {
|
||||
analyticsService.trackError(
|
||||
VoiceMessageException.PlayMessageError("Error while trying to play voice message", it)
|
||||
)
|
||||
it
|
||||
},
|
||||
) {
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is VoiceMessageEvents.Seek -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue