mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Handle number of batches / last batch
This commit is contained in:
@@ -50,6 +50,10 @@ final class PollHistoryService: PollHistoryServiceProtocol {
|
||||
func nextBatch() -> AnyPublisher<TimelinePollDetails, Error> {
|
||||
currentBatchSubject?.eraseToAnyPublisher() ?? startPagination()
|
||||
}
|
||||
|
||||
var hasNextBatch: Bool {
|
||||
timeline.canPaginate(.backwards)
|
||||
}
|
||||
}
|
||||
|
||||
private extension PollHistoryService {
|
||||
|
||||
@@ -17,6 +17,15 @@
|
||||
import Combine
|
||||
|
||||
final class MockPollHistoryService: PollHistoryServiceProtocol {
|
||||
lazy var nextBatchPublisher: AnyPublisher<TimelinePollDetails, Error> = (activePollsData + pastPollsData)
|
||||
.publisher
|
||||
.setFailureType(to: Error.self)
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
func nextBatch() -> AnyPublisher<TimelinePollDetails, Error> {
|
||||
nextBatchPublisher
|
||||
}
|
||||
|
||||
var updatesPublisher: AnyPublisher<TimelinePollDetails, Never> = Empty().eraseToAnyPublisher()
|
||||
var updates: AnyPublisher<TimelinePollDetails, Never> {
|
||||
updatesPublisher
|
||||
@@ -27,14 +36,7 @@ final class MockPollHistoryService: PollHistoryServiceProtocol {
|
||||
pollErrorPublisher
|
||||
}
|
||||
|
||||
lazy var nextBatchPublisher: AnyPublisher<TimelinePollDetails, Error> = (activePollsData + pastPollsData)
|
||||
.publisher
|
||||
.setFailureType(to: Error.self)
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
func nextBatch() -> AnyPublisher<TimelinePollDetails, Error> {
|
||||
nextBatchPublisher
|
||||
}
|
||||
var hasNextBatch: Bool = true
|
||||
}
|
||||
|
||||
private extension MockPollHistoryService {
|
||||
|
||||
@@ -27,4 +27,8 @@ protocol PollHistoryServiceProtocol {
|
||||
/// Publishes errors regarding poll aggregations.
|
||||
/// Note: `nextBatch()` will continue to publish new polls even if some poll isn't being aggregated correctly.
|
||||
var pollErrors: AnyPublisher<Error, Never> { get }
|
||||
|
||||
/// Returns true every time the service can fetch another batch.
|
||||
/// There is no guarantee the `nextBatch()` returned publisher will publish something anyway.
|
||||
var hasNextBatch: Bool { get }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user