From 14d742d5040a21d6a927120fadabfe3ab7abf66f Mon Sep 17 00:00:00 2001 From: yostyle Date: Fri, 3 Feb 2023 11:59:37 +0100 Subject: [PATCH] Not start broadcasting if there is already a live broadcast in the room --- .../usecase/GetVoiceBroadcastStateEventUseCase.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/voicebroadcast/usecase/GetVoiceBroadcastStateEventUseCase.kt b/vector/src/main/java/im/vector/app/features/voicebroadcast/usecase/GetVoiceBroadcastStateEventUseCase.kt index e821e09119..d1b1c21b57 100644 --- a/vector/src/main/java/im/vector/app/features/voicebroadcast/usecase/GetVoiceBroadcastStateEventUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/voicebroadcast/usecase/GetVoiceBroadcastStateEventUseCase.kt @@ -49,14 +49,15 @@ class GetVoiceBroadcastStateEventUseCase @Inject constructor( * Get the most recent event related to the given voice broadcast. */ private fun getMostRecentRelatedEvent(room: Room, voiceBroadcast: VoiceBroadcast): VoiceBroadcastEvent? { - val startedEvent = room.getTimelineEvent(voiceBroadcast.voiceBroadcastId) - return if (startedEvent?.root?.isRedacted().orTrue()) { + val startedEvent = room.getTimelineEvent(voiceBroadcast.voiceBroadcastId)?.root + return if (startedEvent?.isRedacted().orTrue()) { null } else { room.timelineService().getTimelineEventsRelatedTo(RelationType.REFERENCE, voiceBroadcast.voiceBroadcastId) .mapNotNull { timelineEvent -> timelineEvent.root.asVoiceBroadcastEvent() } .filterNot { it.root.isRedacted() } .maxByOrNull { it.root.originServerTs ?: 0 } + ?: startedEvent?.asVoiceBroadcastEvent() } } }