diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt index 9bcf3e1b6b..d44713f404 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt @@ -138,19 +138,15 @@ class TimelineItemFactory @Inject constructor( // Crypto EventType.ENCRYPTED -> { val relationContent = event.getRelationContent() - if (event.root.isRedacted()) { + when { // Redacted event, let the MessageItemFactory handle it - messageItemFactory.create(params) - } else if (relationContent?.type == RelationType.REFERENCE) { - // Hide the decryption error for VoiceBroadcast chunks - val startEvent = relationContent.eventId?.let { session.getRoom(event.roomId)?.getTimelineEvent(it) } - if (startEvent?.isVoiceBroadcast() == false) { - encryptedItemFactory.create(params) - } else { - null + event.root.isRedacted() -> messageItemFactory.create(params) + relationContent?.type == RelationType.REFERENCE -> { + // Hide the decryption error for VoiceBroadcast chunks + val relatedEvent = relationContent.eventId?.let { session.getRoom(event.roomId)?.getTimelineEvent(it) } + if (relatedEvent?.isVoiceBroadcast() != true) encryptedItemFactory.create(params) else null } - } else { - encryptedItemFactory.create(params) + else -> encryptedItemFactory.create(params) } } EventType.KEY_VERIFICATION_CANCEL, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceBroadcastListeningItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceBroadcastListeningItem.kt index 36a6eb93a2..b9d70b51cb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceBroadcastListeningItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceBroadcastListeningItem.kt @@ -137,15 +137,19 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageVoiceBroadcastItem private fun renderPlaybackError(holder: Holder, playbackState: State) { with(holder) { - if (playbackState is State.Error) { - controlsGroup.isVisible = false - errorView.setTextOrHide(errorFormatter.toHumanReadable(playbackState.failure)) - } else if (playbackState is State.Idle && hasUnableToDecryptEvent) { - controlsGroup.isVisible = false - errorView.setTextOrHide(errorFormatter.toHumanReadable(VoiceBroadcastFailure.ListeningError.UnableToDecrypt)) - } else { - errorView.isVisible = false - controlsGroup.isVisible = true + when { + playbackState is State.Error -> { + controlsGroup.isVisible = false + errorView.setTextOrHide(errorFormatter.toHumanReadable(playbackState.failure)) + } + playbackState is State.Idle && hasUnableToDecryptEvent -> { + controlsGroup.isVisible = false + errorView.setTextOrHide(errorFormatter.toHumanReadable(VoiceBroadcastFailure.ListeningError.UnableToDecrypt)) + } + else -> { + errorView.isVisible = false + controlsGroup.isVisible = true + } } } } diff --git a/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/usecase/GetLiveVoiceBroadcastChunksUseCase.kt b/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/usecase/GetLiveVoiceBroadcastChunksUseCase.kt index 05a465fb13..5a95f1a256 100644 --- a/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/usecase/GetLiveVoiceBroadcastChunksUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/usecase/GetLiveVoiceBroadcastChunksUseCase.kt @@ -146,7 +146,9 @@ class GetLiveVoiceBroadcastChunksUseCase @Inject constructor( it.isVoiceBroadcast() && it.getVoiceBroadcastEventId() == voiceBroadcastId && it.root.senderId == senderId }?.root } - event.getClearType() == EventType.ENCRYPTED && relationContent?.type == RelationType.REFERENCE -> event + event.getClearType() == EventType.ENCRYPTED && relationContent?.type == RelationType.REFERENCE -> { + event.takeIf { relationContent.eventId == voiceBroadcastId } + } else -> null } }