fixed bug in refreshcontroller

Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
Matt Bruce 2025-01-21 13:08:44 -06:00
parent 4f0d099f60
commit b9bd3ae310
2 changed files with 3 additions and 4 deletions

View File

@ -112,7 +112,6 @@ class EmployeesViewController: UIViewController {
.sink { [weak self] _ in .sink { [weak self] _ in
self?.updateFooter() self?.updateFooter()
self?.tableView.reloadData() self?.tableView.reloadData()
self?.tableView.refreshControl?.endRefreshing()
} }
.store(in: &cancellables) .store(in: &cancellables)
@ -123,6 +122,7 @@ class EmployeesViewController: UIViewController {
self?.activityIndicator.startAnimating() self?.activityIndicator.startAnimating()
} else { } else {
self?.activityIndicator.stopAnimating() self?.activityIndicator.stopAnimating()
self?.tableView.refreshControl?.endRefreshing() // End refresh control
} }
} }
.store(in: &cancellables) .store(in: &cancellables)

View File

@ -65,13 +65,12 @@ public class EmployeesViewModel: ObservableObject {
totalEmployees = wrapper.total totalEmployees = wrapper.total
currentPage = page currentPage = page
hasMorePages = employees.count < totalEmployees hasMorePages = employees.count < totalEmployees
isLoading = false
} catch { } catch {
// Handle errors // Handle errors
isLoading = false
errorMessage = "An unexpected error occurred, please try to refresh." errorMessage = "An unexpected error occurred, please try to refresh."
} }
isLoading = false
} }
} }