Set id to VoiceBroadcast items

This commit is contained in:
Florian Renaud 2022-10-20 22:45:22 +02:00
parent 8869d82dd0
commit 9a96de4f06
1 changed files with 11 additions and 2 deletions

View File

@ -62,9 +62,15 @@ class VoiceBroadcastItemFactory @Inject constructor(
val mostRecentEvent = mostRecentTimelineEvent.root.asVoiceBroadcastEvent() val mostRecentEvent = mostRecentTimelineEvent.root.asVoiceBroadcastEvent()
val mostRecentMessageContent = mostRecentEvent?.content ?: return null val mostRecentMessageContent = mostRecentEvent?.content ?: return null
val isRecording = mostRecentMessageContent.voiceBroadcastState != VoiceBroadcastState.STOPPED && mostRecentEvent.root.stateKey == session.myUserId val isRecording = mostRecentMessageContent.voiceBroadcastState != VoiceBroadcastState.STOPPED && mostRecentEvent.root.stateKey == session.myUserId
val recorderName = mostRecentTimelineEvent.root.stateKey?.let { session.getUser(it) }?.displayName ?: mostRecentTimelineEvent.root.stateKey val recorderName = mostRecentTimelineEvent.root.stateKey?.let { session.getUser(it) }?.displayName ?: mostRecentTimelineEvent.root.stateKey
return if (isRecording) { return if (isRecording) {
createRecordingItem(params.event.roomId, highlight, callback, attributes) createRecordingItem(
params.event.roomId,
eventsGroup.groupId,
highlight,
callback,
attributes
)
} else { } else {
createListeningItem( createListeningItem(
params.event.roomId, params.event.roomId,
@ -80,12 +86,14 @@ class VoiceBroadcastItemFactory @Inject constructor(
private fun createRecordingItem( private fun createRecordingItem(
roomId: String, roomId: String,
voiceBroadcastId: String,
highlight: Boolean, highlight: Boolean,
callback: TimelineEventController.Callback?, callback: TimelineEventController.Callback?,
attributes: AbsMessageItem.Attributes, attributes: AbsMessageItem.Attributes,
): MessageVoiceBroadcastRecordingItem { ): MessageVoiceBroadcastRecordingItem {
val roomSummary = session.getRoom(roomId)?.roomSummary() val roomSummary = session.getRoom(roomId)?.roomSummary()
return MessageVoiceBroadcastRecordingItem_() return MessageVoiceBroadcastRecordingItem_()
.id("voice_broadcast_$voiceBroadcastId")
.attributes(attributes) .attributes(attributes)
.highlighted(highlight) .highlighted(highlight)
.roomItem(roomSummary?.toMatrixItem()) .roomItem(roomSummary?.toMatrixItem())
@ -107,6 +115,7 @@ class VoiceBroadcastItemFactory @Inject constructor(
): MessageVoiceBroadcastListeningItem { ): MessageVoiceBroadcastListeningItem {
val roomSummary = session.getRoom(roomId)?.roomSummary() val roomSummary = session.getRoom(roomId)?.roomSummary()
return MessageVoiceBroadcastListeningItem_() return MessageVoiceBroadcastListeningItem_()
.id("voice_broadcast_$voiceBroadcastId")
.attributes(attributes) .attributes(attributes)
.highlighted(highlight) .highlighted(highlight)
.roomItem(roomSummary?.toMatrixItem()) .roomItem(roomSummary?.toMatrixItem())