mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add voice message rendering to the timeline (#1776)
This commit is contained in:
+10
@@ -82,6 +82,16 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
|
||||
func retryDecryption(for sessionID: String) async { }
|
||||
|
||||
func playbackViewState(for itemID: TimelineItemIdentifier) -> VoiceRoomPlaybackViewState? {
|
||||
VoiceRoomPlaybackViewState(duration: 10.0,
|
||||
waveform: nil,
|
||||
progress: 0.0)
|
||||
}
|
||||
|
||||
func playPauseAudio(for itemID: TimelineItemIdentifier) async { }
|
||||
|
||||
func seekAudio(for itemID: TimelineItemIdentifier, progress: Double) async { }
|
||||
|
||||
// MARK: - UI Test signalling
|
||||
|
||||
/// The cancellable used for UI Tests signalling.
|
||||
|
||||
@@ -36,7 +36,8 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
let callbacks = PassthroughSubject<RoomTimelineControllerCallback, Never>()
|
||||
|
||||
private(set) var timelineItems = [RoomTimelineItemProtocol]()
|
||||
|
||||
private var timelineAudioPlaybackViewStates = [TimelineItemIdentifier: VoiceRoomPlaybackViewState]()
|
||||
|
||||
var roomID: String {
|
||||
roomProxy.id
|
||||
}
|
||||
@@ -220,6 +221,34 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
func retryDecryption(for sessionID: String) async {
|
||||
await roomProxy.retryDecryption(for: sessionID)
|
||||
}
|
||||
|
||||
func playbackViewState(for itemID: TimelineItemIdentifier) -> VoiceRoomPlaybackViewState? {
|
||||
guard let timelineItem = timelineItems.firstUsingStableID(itemID) else {
|
||||
MXLog.error("timelineItem not found")
|
||||
return .none
|
||||
}
|
||||
|
||||
switch timelineItem {
|
||||
case let item as VoiceRoomTimelineItem:
|
||||
if let playbackViewState = timelineAudioPlaybackViewStates[itemID] {
|
||||
return playbackViewState
|
||||
}
|
||||
let playbackViewState = VoiceRoomPlaybackViewState(duration: item.content.duration,
|
||||
waveform: item.content.waveform)
|
||||
timelineAudioPlaybackViewStates[itemID] = playbackViewState
|
||||
return playbackViewState
|
||||
default:
|
||||
return .none
|
||||
}
|
||||
}
|
||||
|
||||
func playPauseAudio(for itemID: TimelineItemIdentifier) async { }
|
||||
|
||||
func seekAudio(for itemID: TimelineItemIdentifier, progress: Double) async {
|
||||
Task {
|
||||
timelineAudioPlaybackViewStates[itemID]?.updateState(progress: progress)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
+6
@@ -64,6 +64,12 @@ protocol RoomTimelineControllerProtocol {
|
||||
func debugInfo(for itemID: TimelineItemIdentifier) -> TimelineItemDebugInfo
|
||||
|
||||
func retryDecryption(for sessionID: String) async
|
||||
|
||||
func playbackViewState(for itemID: TimelineItemIdentifier) -> VoiceRoomPlaybackViewState?
|
||||
|
||||
func playPauseAudio(for itemID: TimelineItemIdentifier) async
|
||||
|
||||
func seekAudio(for itemID: TimelineItemIdentifier, progress: Double) async
|
||||
}
|
||||
|
||||
extension RoomTimelineControllerProtocol {
|
||||
|
||||
Reference in New Issue
Block a user