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
@@ -241,11 +241,19 @@ enum RoomTimelineItemFixtures {
static var outgoingPolls: [RoomTimelineItemProtocol] {
[PollRoomTimelineItem.mock(poll: .disclosed(createdByAccountOwner: true), isOutgoing: true)]
}
static var permalinkChunk: [RoomTimelineItemProtocol] {
(1...20).map { index in
TextRoomTimelineItem(id: .init(timelineID: "\(index)", eventID: "$\(index)"),
text: "Message ID \(index)",
senderDisplayName: index > 10 ? "Alice" : "Bob")
}
}
}
private extension TextRoomTimelineItem {
init(text: String, senderDisplayName: String) {
self.init(id: .random,
init(id: TimelineItemIdentifier? = nil, text: String, senderDisplayName: String) {
self.init(id: id ?? .random,
timestamp: "10:47 am",
isOutgoing: senderDisplayName == "Alice",
isEditable: false,
@@ -66,8 +66,12 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
activeTimeline = timeline
activeTimelineProvider = timeline.timelineProvider
return .success(())
case .failure:
return .failure(.generic)
case .failure(let error):
if case .eventNotFound = error {
return .failure(.eventNotFound)
} else {
return .failure(.generic)
}
}
}
@@ -32,6 +32,7 @@ enum RoomTimelineControllerAction {
enum RoomTimelineControllerError: Error {
case generic
case eventNotFound
}
@MainActor