mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 19:56:57 +02:00
VB: Make the view model aware of every chunk new coming
this reactive approach will help to cache and reorder them by sequence
This commit is contained in:
@@ -28,15 +28,19 @@ struct VoiceBroadcastBuilder {
|
||||
var voiceBroadcast = VoiceBroadcast()
|
||||
|
||||
voiceBroadcast.chunks = Set(events.compactMap { event in
|
||||
guard let attachment = MXKAttachment(event: event, andMediaManager: mediaManager),
|
||||
let chunkInfo = event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] as? [String: UInt],
|
||||
let sequence = chunkInfo[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkSequence] else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return VoiceBroadcastChunk(voiceBroadcastInfoEventId: voiceBroadcastStartEventId, sequence: sequence, attachment: attachment)
|
||||
buildChunk(event: event, mediaManager: mediaManager, voiceBroadcastStartEventId: voiceBroadcastStartEventId)
|
||||
})
|
||||
|
||||
return voiceBroadcast
|
||||
}
|
||||
|
||||
func buildChunk(event: MXEvent, mediaManager: MXMediaManager, voiceBroadcastStartEventId: String) -> VoiceBroadcastChunk? {
|
||||
guard let attachment = MXKAttachment(event: event, andMediaManager: mediaManager),
|
||||
let chunkInfo = event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] as? [String: UInt],
|
||||
let sequence = chunkInfo[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkSequence] else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return VoiceBroadcastChunk(voiceBroadcastInfoEventId: voiceBroadcastStartEventId, sequence: sequence, attachment: attachment)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user