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
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,

View File

@ -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
}
}
}
}

View File

@ -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
}
}