mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Add mechanism for opening up a threaded timeline
This commit is contained in:
committed by
Stefan Ceriu
parent
2f938d3cbf
commit
10fb2b5dda
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
|
||||
|
||||
func timelineFocusedOnEvent(eventID: String, numberOfEvents: UInt16) async -> Result<TimelineProxyProtocol, RoomProxyError>
|
||||
|
||||
func threadTimeline(eventID: String) async -> Result<TimelineProxyProtocol, RoomProxyError>
|
||||
|
||||
func messageFilteredTimeline(focus: TimelineFocus,
|
||||
allowedMessageTypes: [TimelineAllowedMessageType],
|
||||
presentation: TimelineKind.MediaPresentation) async -> Result<TimelineProxyProtocol, RoomProxyError>
|
||||
|
||||
@@ -21,6 +21,23 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol {
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
}
|
||||
|
||||
func buildThreadTimelineController(eventID: String,
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
mediaProvider: MediaProviderProtocol) async -> Result<TimelineControllerProtocol, TimelineFactoryControllerError> {
|
||||
switch await roomProxy.threadTimeline(eventID: eventID) {
|
||||
case .success(let timelineProxy):
|
||||
return .success(TimelineController(roomProxy: roomProxy,
|
||||
timelineProxy: timelineProxy,
|
||||
initialFocussedEventID: nil,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
mediaProvider: mediaProvider,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
case .failure(let error):
|
||||
return .failure(.roomProxyError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func buildPinnedEventsTimelineController(roomProxy: JoinedRoomProxyProtocol,
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
mediaProvider: MediaProviderProtocol) async -> TimelineControllerProtocol? {
|
||||
|
||||
+5
@@ -19,6 +19,11 @@ protocol TimelineControllerFactoryProtocol {
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
mediaProvider: MediaProviderProtocol) -> TimelineControllerProtocol
|
||||
|
||||
func buildThreadTimelineController(eventID: String,
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
mediaProvider: MediaProviderProtocol) async -> Result<TimelineControllerProtocol, TimelineFactoryControllerError>
|
||||
|
||||
func buildPinnedEventsTimelineController(roomProxy: JoinedRoomProxyProtocol,
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
mediaProvider: MediaProviderProtocol) async -> TimelineControllerProtocol?
|
||||
|
||||
@@ -97,7 +97,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
switch kind {
|
||||
case .live:
|
||||
return await paginateBackwardsOnLive(requestSize: requestSize)
|
||||
case .detached, .media:
|
||||
case .detached, .media, .thread:
|
||||
return await focussedPaginate(.backwards, requestSize: requestSize)
|
||||
case .pinned:
|
||||
return .success(())
|
||||
@@ -596,7 +596,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
MXLog.error("Failed to subscribe to back pagination status with error: \(error)")
|
||||
}
|
||||
forwardPaginationStatusSubject.send(.timelineEndReached)
|
||||
case .detached:
|
||||
case .detached, .thread:
|
||||
// Detached timelines don't support observation, set the initial state ourself.
|
||||
backPaginationStatusSubject.send(.idle)
|
||||
forwardPaginationStatusSubject.send(.idle)
|
||||
|
||||
@@ -13,6 +13,7 @@ enum TimelineKind: Equatable {
|
||||
case live
|
||||
case detached
|
||||
case pinned
|
||||
case thread
|
||||
|
||||
enum MediaPresentation { case roomScreenLive, roomScreenDetached, pinnedEventsScreen, mediaFilesScreen }
|
||||
case media(MediaPresentation)
|
||||
@@ -21,6 +22,7 @@ enum TimelineKind: Equatable {
|
||||
enum TimelineFocus {
|
||||
case live
|
||||
case eventID(String)
|
||||
case thread(eventID: String)
|
||||
case pinned
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user