mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Support load more in PollHistoryService
This commit is contained in:
@@ -40,6 +40,8 @@ final class PollHistoryViewModel: PollHistoryViewModelType, PollHistoryViewModel
|
||||
fetchFirstBatch()
|
||||
case .segmentDidChange:
|
||||
updateViewState()
|
||||
case .loadMoreContent:
|
||||
fetchMoreContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +63,21 @@ private extension PollHistoryViewModel {
|
||||
.store(in: &subcriptions)
|
||||
}
|
||||
|
||||
func fetchMoreContent() {
|
||||
state.isLoading = true
|
||||
|
||||
pollService
|
||||
.nextBatch()
|
||||
.sink { [weak self] _ in
|
||||
#warning("Handle errors")
|
||||
self?.state.isLoading = false
|
||||
} receiveValue: { [weak self] poll in
|
||||
self?.add(poll: poll)
|
||||
self?.updateViewState()
|
||||
}
|
||||
.store(in: &subcriptions)
|
||||
}
|
||||
|
||||
func setupUpdateSubscriptions() {
|
||||
subcriptions.removeAll()
|
||||
|
||||
@@ -88,6 +105,10 @@ private extension PollHistoryViewModel {
|
||||
polls?[pollIndex] = poll
|
||||
}
|
||||
|
||||
func add(poll: TimelinePollDetails) {
|
||||
polls?.append(poll)
|
||||
}
|
||||
|
||||
func updateViewState() {
|
||||
let renderedPolls: [TimelinePollDetails]?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user