Polls history (#2244)

This commit is contained in:
Nicolas Mauri
2023-12-18 16:38:39 +01:00
committed by GitHub
parent 4ac0ad51d7
commit 72a84badcb
73 changed files with 1516 additions and 202 deletions
@@ -34,6 +34,8 @@ final class TimelineProxy: TimelineProxyProtocol {
private let backPaginationStateSubject = PassthroughSubject<BackPaginationStatus, Never>()
private let timelineUpdatesSubject = PassthroughSubject<[TimelineDiff], Never>()
private(set) var timelineStartReached = false
private let actionsSubject = PassthroughSubject<TimelineProxyAction, Never>()
var actions: AnyPublisher<TimelineProxyAction, Never> {
@@ -134,6 +136,18 @@ final class TimelineProxy: TimelineProxyProtocol {
try? timeline.getTimelineEventContentByEventId(eventId: eventID)
}
func paginateBackwards(requestSize: UInt) async -> Result<Void, TimelineProxyError> {
do {
try await Task.dispatch(on: .global()) {
try self.timeline.paginateBackwards(opts: .simpleRequest(eventLimit: UInt16(requestSize), waitForToken: true))
}
return .success(())
} catch {
return .failure(.failedPaginatingBackwards)
}
}
func paginateBackwards(requestSize: UInt, untilNumberOfItems: UInt) async -> Result<Void, TimelineProxyError> {
do {
try await Task.dispatch(on: .global()) {
@@ -480,6 +494,9 @@ final class TimelineProxy: TimelineProxyProtocol {
private func subscribeToBackpagination() {
let listener = RoomBackpaginationStatusListener { [weak self] status in
if status == .timelineStartReached {
self?.timelineStartReached = true
}
self?.backPaginationStateSubject.send(status)
}
do {