Event Permalink Tweaks (#2754)

* Handle errors focussing the timeline.

* Add a test for focussing on an existing timeline item.
This commit is contained in:
Doug
2024-04-29 10:00:41 +01:00
committed by GitHub
parent 231fc6defb
commit 7b2168a540
12 changed files with 100 additions and 8 deletions
+13 -1
View File
@@ -163,8 +163,20 @@ class RoomProxy: RoomProxyProtocol {
do {
let timeline = try await room.timelineFocusedOnEvent(eventId: eventID, numContextEvents: numberOfEvents, internalIdPrefix: UUID().uuidString)
return .success(TimelineProxy(timeline: timeline, isLive: false))
} catch let error as FocusEventError {
switch error {
case .InvalidEventId(_, let error):
MXLog.error("Invalid event \(eventID) Error: \(error)")
return .failure(.eventNotFound)
case .EventNotFound:
MXLog.error("Event \(eventID) not found.")
return .failure(.eventNotFound)
case .Other(let message):
MXLog.error("Failed to create a timeline focussed on event \(eventID) Error: \(message)")
return .failure(.sdkError(error))
}
} catch {
MXLog.error("Failed to create a timeline focussed on: \(eventID) with error: \(error)")
MXLog.error("Unexpected error: \(error)")
return .failure(.sdkError(error))
}
}
@@ -23,6 +23,7 @@ enum RoomProxyError: Error {
case invalidURL
case invalidMedia
case eventNotFound
}
enum RoomProxyAction {