This commit is contained in:
cheykrym 2025-10-26 01:53:21 +03:00
parent 3f0543aa3a
commit 3e9d6696b0

View File

@ -24,8 +24,11 @@ struct BlockedUsersView: View {
emptyState emptyState
} else { } else {
usersSection usersSection
if hasMore { if isLoading && !blockedUsers.isEmpty {
loadMoreState Section {
ProgressView()
.frame(maxWidth: .infinity, alignment: .center)
}
} }
} }
} }
@ -82,7 +85,8 @@ struct BlockedUsersView: View {
private var usersSection: some View { private var usersSection: some View {
Section(header: Text(NSLocalizedString("Заблокированные", comment: ""))) { Section(header: Text(NSLocalizedString("Заблокированные", comment: ""))) {
ForEach(blockedUsers) { user in ForEach(blockedUsers) {
user in
HStack(spacing: 12) { HStack(spacing: 12) {
Circle() Circle()
.fill(Color.accentColor.opacity(0.15)) .fill(Color.accentColor.opacity(0.15))
@ -113,6 +117,11 @@ struct BlockedUsersView: View {
} }
.disabled(removingUserIds.contains(user.id)) .disabled(removingUserIds.contains(user.id))
} }
.task {
if user == blockedUsers.last, hasMore, !isLoading {
await loadBlockedUsers()
}
}
} }
} }
} }
@ -139,18 +148,6 @@ struct BlockedUsersView: View {
} }
} }
private var loadMoreState: some View {
Section {
ProgressView()
.frame(maxWidth: .infinity, alignment: .center)
.onAppear {
Task {
await loadBlockedUsers()
}
}
}
}
private func errorState(_ message: String) -> some View { private func errorState(_ message: String) -> some View {
Section { Section {
Text(message) Text(message)
@ -166,6 +163,8 @@ struct BlockedUsersView: View {
} }
isLoading = true isLoading = true
defer { isLoading = false }
if offset == 0 { if offset == 0 {
loadError = nil loadError = nil
} }
@ -183,8 +182,6 @@ struct BlockedUsersView: View {
activeAlert = .error(message: message) activeAlert = .error(message: message)
if AppConfig.DEBUG { print("[BlockedUsersView] load blocked users failed: \(error)") } if AppConfig.DEBUG { print("[BlockedUsersView] load blocked users failed: \(error)") }
} }
isLoading = false
} }
@MainActor @MainActor