fix pagination load

This commit is contained in:
cheykrym 2025-10-26 02:57:47 +03:00
parent 526a57b556
commit 8568f6c20e

View File

@ -80,10 +80,10 @@ struct BlockedUsersView: View {
private var usersSection: some View {
Section(header: Text(NSLocalizedString("Заблокированные", comment: ""))) {
ForEach(blockedUsers) { user in
userRow(user)
ForEach(Array(blockedUsers.enumerated()), id: \.element.id) { index, user in
userRow(user, index: index)
}
if isLoading {
if isLoading && !blockedUsers.isEmpty {
Text("Идет загрузка...")
.foregroundColor(.gray)
.frame(maxWidth: .infinity, alignment: .center)
@ -99,7 +99,7 @@ struct BlockedUsersView: View {
}
}
private func userRow(_ user: BlockedUser) -> some View {
private func userRow(_ user: BlockedUser, index: Int) -> some View {
HStack(spacing: 12) {
Circle()
.fill(Color.accentColor.opacity(0.15))
@ -131,7 +131,7 @@ struct BlockedUsersView: View {
.disabled(removingUserIds.contains(user.id))
}
.onAppear {
if user.id == blockedUsers.last?.id {
if index >= blockedUsers.count - 5 {
Task {
await loadBlockedUsers()
}