Merge pull request #7656 from vector-im/feature/fre/voice_broadcast_room_attachments

[Voice Broadcast] Remove chunks from the room attachments
This commit is contained in:
Florian Renaud 2022-11-29 17:43:42 +01:00 committed by GitHub
commit 4b3e36da91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

1
changelog.d/7656.wip Normal file
View file

@ -0,0 +1 @@
Voice Broadcast - Remove voice messages related to a VB from the room attachments

View file

@ -22,7 +22,6 @@ import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
import im.vector.app.features.voicebroadcast.isVoiceBroadcast
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.RelationType
@ -257,7 +256,7 @@ class TimelineEventVisibilityHelper @Inject constructor(
return true
}
if (root.asMessageAudioEvent()?.isVoiceBroadcast().orFalse()) {
if (root.asMessageAudioEvent().isVoiceBroadcast()) {
return true
}

View file

@ -26,10 +26,12 @@ import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.voicebroadcast.isVoiceBroadcast
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.getRoom
import org.matrix.android.sdk.api.session.room.model.message.MessageType
import org.matrix.android.sdk.api.session.room.model.message.asMessageAudioEvent
import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.flow.unwrap
@ -78,6 +80,8 @@ class RoomUploadsViewModel @AssistedInject constructor(
token = result.nextToken
val groupedUploadEvents = result.uploadEvents
// Remove voice broadcast chunks from the attachments
.filterNot { it.root.asMessageAudioEvent().isVoiceBroadcast() }
.groupBy {
it.contentWithAttachmentContent.msgType == MessageType.MSGTYPE_IMAGE ||
it.contentWithAttachmentContent.msgType == MessageType.MSGTYPE_VIDEO