Fix PR comments

This commit is contained in:
yostyle 2023-02-02 11:28:20 +01:00
parent 369c0f166d
commit e7f3cf6d57
3 changed files with 23 additions and 21 deletions

View File

@ -138,19 +138,15 @@ class TimelineItemFactory @Inject constructor(
// Crypto // Crypto
EventType.ENCRYPTED -> { EventType.ENCRYPTED -> {
val relationContent = event.getRelationContent() val relationContent = event.getRelationContent()
if (event.root.isRedacted()) { when {
// Redacted event, let the MessageItemFactory handle it // Redacted event, let the MessageItemFactory handle it
messageItemFactory.create(params) event.root.isRedacted() -> messageItemFactory.create(params)
} else if (relationContent?.type == RelationType.REFERENCE) { relationContent?.type == RelationType.REFERENCE -> {
// Hide the decryption error for VoiceBroadcast chunks // Hide the decryption error for VoiceBroadcast chunks
val startEvent = relationContent.eventId?.let { session.getRoom(event.roomId)?.getTimelineEvent(it) } val relatedEvent = relationContent.eventId?.let { session.getRoom(event.roomId)?.getTimelineEvent(it) }
if (startEvent?.isVoiceBroadcast() == false) { if (relatedEvent?.isVoiceBroadcast() != true) encryptedItemFactory.create(params) else null
encryptedItemFactory.create(params)
} else {
null
} }
} else { else -> encryptedItemFactory.create(params)
encryptedItemFactory.create(params)
} }
} }
EventType.KEY_VERIFICATION_CANCEL, EventType.KEY_VERIFICATION_CANCEL,

View File

@ -137,15 +137,19 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageVoiceBroadcastItem
private fun renderPlaybackError(holder: Holder, playbackState: State) { private fun renderPlaybackError(holder: Holder, playbackState: State) {
with(holder) { with(holder) {
if (playbackState is State.Error) { when {
controlsGroup.isVisible = false playbackState is State.Error -> {
errorView.setTextOrHide(errorFormatter.toHumanReadable(playbackState.failure)) controlsGroup.isVisible = false
} else if (playbackState is State.Idle && hasUnableToDecryptEvent) { errorView.setTextOrHide(errorFormatter.toHumanReadable(playbackState.failure))
controlsGroup.isVisible = false }
errorView.setTextOrHide(errorFormatter.toHumanReadable(VoiceBroadcastFailure.ListeningError.UnableToDecrypt)) playbackState is State.Idle && hasUnableToDecryptEvent -> {
} else { controlsGroup.isVisible = false
errorView.isVisible = false errorView.setTextOrHide(errorFormatter.toHumanReadable(VoiceBroadcastFailure.ListeningError.UnableToDecrypt))
controlsGroup.isVisible = true }
else -> {
errorView.isVisible = false
controlsGroup.isVisible = true
}
} }
} }
} }

View File

@ -146,7 +146,9 @@ class GetLiveVoiceBroadcastChunksUseCase @Inject constructor(
it.isVoiceBroadcast() && it.getVoiceBroadcastEventId() == voiceBroadcastId && it.root.senderId == senderId it.isVoiceBroadcast() && it.getVoiceBroadcastEventId() == voiceBroadcastId && it.root.senderId == senderId
}?.root }?.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 else -> null
} }
} }