Refine loading logic

This commit is contained in:
Alfonso Grillo
2023-01-20 12:25:52 +01:00
parent 729da6d6e3
commit aea4770736
4 changed files with 29 additions and 11 deletions
@@ -65,15 +65,15 @@ private extension PollHistoryViewModel {
pollService
.isFetching
.filter { $0 }
.first()
.sink { isFetching in
self.state.loadingState = .loading(firstLoad: true)
self.state.loadingState = isFetching ? .loading(firstLoad: true) : .idle
}
.store(in: &subcriptions)
pollService
.isFetching
.dropFirst()
.sink { isFetching in
self.state.loadingState = isFetching ? .loading(firstLoad: false) : .idle
}