mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fix for a potential crash when building a removed timeline item. (#2533)
This commit is contained in:
@@ -503,7 +503,9 @@ class RoomScreenInteractionHandler {
|
|||||||
await voiceMessageRecorder.stopRecording()
|
await voiceMessageRecorder.stopRecording()
|
||||||
}
|
}
|
||||||
|
|
||||||
let audioPlayerState = audioPlayerState(for: itemID)
|
guard let audioPlayerState = audioPlayerState(for: itemID) else {
|
||||||
|
fatalError("Audio player not found for \(itemID)")
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure this one is attached
|
// Ensure this one is attached
|
||||||
if !audioPlayerState.isAttached {
|
if !audioPlayerState.isAttached {
|
||||||
@@ -546,13 +548,15 @@ class RoomScreenInteractionHandler {
|
|||||||
await playerState.updateState(progress: progress)
|
await playerState.updateState(progress: progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func audioPlayerState(for itemID: TimelineItemIdentifier) -> AudioPlayerState {
|
func audioPlayerState(for itemID: TimelineItemIdentifier) -> AudioPlayerState? {
|
||||||
guard let timelineItem = timelineController.timelineItems.firstUsingStableID(itemID) else {
|
guard let timelineItem = timelineController.timelineItems.firstUsingStableID(itemID) else {
|
||||||
fatalError("TimelineItem \(itemID) not found")
|
MXLog.error("TimelineItem \(itemID) not found")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let voiceMessageRoomTimelineItem = timelineItem as? VoiceMessageRoomTimelineItem else {
|
guard let voiceMessageRoomTimelineItem = timelineItem as? VoiceMessageRoomTimelineItem else {
|
||||||
fatalError("Invalid TimelineItem type (expecting `VoiceMessageRoomTimelineItem` but found \(type(of: timelineItem)) instead")
|
MXLog.error("Invalid TimelineItem type (expecting `VoiceMessageRoomTimelineItem` but found \(type(of: timelineItem)) instead")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if let playerState = mediaPlayerProvider.playerState(for: .timelineItemIdentifier(itemID)) {
|
if let playerState = mediaPlayerProvider.playerState(for: .timelineItemIdentifier(itemID)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user