Add mechanism for opening up a threaded timeline

This commit is contained in:
Stefan Ceriu
2025-04-11 15:41:06 +03:00
committed by Stefan Ceriu
parent 2f938d3cbf
commit 10fb2b5dda
22 changed files with 505 additions and 13 deletions
@@ -190,6 +190,24 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}
}
func threadTimeline(eventID: String) async -> Result<TimelineProxyProtocol, RoomProxyError> {
do {
let sdkTimeline = try await room.timelineWithConfiguration(configuration: .init(focus: .thread(rootEventId: eventID, numEvents: 20),
filter: .all,
internalIdPrefix: UUID().uuidString,
dateDividerMode: .daily,
trackReadReceipts: true))
let timeline = TimelineProxy(timeline: sdkTimeline, kind: .thread)
await timeline.subscribeForUpdates()
return .success(timeline)
} catch {
MXLog.error("Unexpected error: \(error)")
return .failure(.sdkError(error))
}
}
func messageFilteredTimeline(focus: TimelineFocus,
allowedMessageTypes: [TimelineAllowedMessageType],
presentation: TimelineKind.MediaPresentation) async -> Result<any TimelineProxyProtocol, RoomProxyError> {
@@ -197,6 +215,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
let rustFocus: MatrixRustSDK.TimelineFocus = switch focus {
case .live: .live
case .eventID(let eventID): .event(eventId: eventID, numContextEvents: 100)
case .thread(let eventID): .thread(rootEventId: eventID, numEvents: 20)
case .pinned: .pinnedEvents(maxEventsToLoad: 100, maxConcurrentRequests: 10)
}