mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Add loading view
This commit is contained in:
@@ -28,7 +28,7 @@ final class PollHistoryViewModel: PollHistoryViewModelType, PollHistoryViewModel
|
||||
|
||||
init(mode: PollHistoryMode, pollService: PollHistoryServiceProtocol) {
|
||||
self.pollService = pollService
|
||||
super.init(initialViewState: PollHistoryViewState(mode: mode))
|
||||
super.init(initialViewState: PollHistoryViewState(mode: mode, loadingState: .loading(firstLoad: true)))
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -37,7 +37,7 @@ final class PollHistoryViewModel: PollHistoryViewModelType, PollHistoryViewModel
|
||||
switch viewAction {
|
||||
case .viewAppeared:
|
||||
setupSubscriptions()
|
||||
pollService.startFetching()
|
||||
pollService.next()
|
||||
case .segmentDidChange:
|
||||
updatePolls()
|
||||
}
|
||||
@@ -62,6 +62,22 @@ private extension PollHistoryViewModel {
|
||||
#warning("Handle errors")
|
||||
}
|
||||
.store(in: &subcriptions)
|
||||
|
||||
pollService
|
||||
.isFetching
|
||||
.filter { $0 }
|
||||
.first()
|
||||
.sink { isFetching in
|
||||
self.state.loadingState = .loading(firstLoad: true)
|
||||
}
|
||||
.store(in: &subcriptions)
|
||||
|
||||
pollService
|
||||
.isFetching
|
||||
.sink { isFetching in
|
||||
self.state.loadingState = isFetching ? .loading(firstLoad: false) : .idle
|
||||
}
|
||||
.store(in: &subcriptions)
|
||||
}
|
||||
|
||||
func updatePolls() {
|
||||
|
||||
Reference in New Issue
Block a user