-
Notifications
You must be signed in to change notification settings - Fork 858
Voice Broadcast - Handle event deletion when listening or recording #7629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Voice Broadcast - Handle event deletion when listening or recording #7629
Conversation
| private val getVoiceBroadcastEventUseCase: GetMostRecentVoiceBroadcastStateEventUseCase | ||
| ) : AbstractVoiceRecorderQ(context), VoiceBroadcastRecorder { | ||
|
|
||
| private val session get() = sessionHolder.getActiveSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered it may throw an exception when getting the session variable?
| class ResumeVoiceBroadcastUseCase @Inject constructor( | ||
| private val session: Session, | ||
| private val voiceBroadcastRecorder: VoiceBroadcastRecorder?, | ||
| private val session: Session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the trailing comma?
| val currentRemainingTime: Long? | ||
|
|
||
| fun startRecord(roomId: String, chunkLength: Int, maxLength: Int) | ||
| fun startRecordVoiceBroadcast(voiceBroadcast: VoiceBroadcast, chunkLength: Int, maxLength: Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we need to add VoiceBroadcast in the name of the method? I personnally think this is enough with startRecord since first parameter is a VoiceBroadcast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My problem is that I want to distinguish this method from the startRecord which is inherited from VoiceRecorder to avoid confusion. Ideally, I would like to only expose this one to the outside and change the visibility of the other method to "protected", but afaik I can do it programmatically but this is a bit ugly imo. Wdyt @mnaturel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I didn't see the method in the VoiceRecorder Interface. Let's keep it like this then.
|
|
||
| startRecording(room, eventId, chunkLength, maxLength) | ||
| val voiceBroadcast = VoiceBroadcast(roomId = room.roomId, voiceBroadcastId = eventId) | ||
| room.flow().liveTimelineEvent(eventId).unwrap().first() // wait for the event come back from the sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to update the related unit tests to take this change into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but I was stuck with an infinite loading on the Flow, I added a todo to not forget to update the related test
| import timber.log.Timber | ||
| import javax.inject.Inject | ||
|
|
||
| class GetMostRecentVoiceBroadcastStateEventUseCase @Inject constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this use case needs some unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest doing it in a dedicated PR to unblock this one, I created an issue with the missing tests to track this one
| flowOf(Optional.empty()) | ||
| } else { | ||
| // otherwise, observe most recent event changes | ||
| getMostRecentRelatedEventFlow(room, voiceBroadcast) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you thought about this way of writing this logic?
getMostRecentRelatedEventFlow(room, voiceBroadcast)
.transformWhile { mostRecentEvent ->
val hasValue = mostRecentEvent.hasValue()
if(hasValue) {
// keep the most recent event
emit(mostRecentEvent)
} else {
// no most recent event, fallback to started event
emit(startedEvent)
}
hasValue
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely prefer this format, updated aa53105
| event.hasValue() && event.get().root.isRedacted().not() | ||
| } | ||
| .flatMapLatest { event -> | ||
| if (event.getOrNull()?.root?.isRedacted().orFalse()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was your intention when event is null? The comment says it should be in this if branch but using orFalse means it will go through the else branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I fixed and rewrote the condition for better clarity
mnaturel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some small comments.
Just a general thought about redaction of voice broadcast events. For the default user, when pressing the "Remove" button on a voice broadcast, it seems it only redacts the started event. It is intended? I expected it redacts every associated events of the given voice broadcast (message events + state events).
f59be73 to
a8f3bb1
Compare
0e74402 to
81a2a10
Compare
…oadcast state event
81a2a10 to
f85f4cf
Compare
f85f4cf to
620bebc
Compare
|
SonarCloud Quality Gate failed. |
mnaturel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the updates!
I have just a general question: I have seen when removing from the tile of a voice broadcast, it actually doesn't remove all the related events like messages or related state events to the original event. As a user, I would expect it redacts every related events to the selected voice broadcast. Can you confirm it will be implemented this way in the future?
Sorry, I forgot to answer this question, indeed it is not done for the moment but we'll implement the proper redaction of all the related events in a dedicated PR by using this MSC |








Type of change
Content
Handle the deletion of a voice broadcast state event on the recorder and the listener sides.
startedevent is redactedstartedevent is redactedMotivation and context
Continue #7127
Screenshots / GIFs
Tests
Test again during recording and listening to the VB, delete the started event should stop the action.
Tested devices
Checklist