From 9653ac2b292bce6374db5bdfdedf90946d2c10c1 Mon Sep 17 00:00:00 2001 From: Marcin Czachurski Date: Wed, 26 Apr 2023 16:40:46 +0200 Subject: [PATCH] #49 Fix issue with not connected actions to buttons --- Vernissage/Views/FollowRequestsView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Vernissage/Views/FollowRequestsView.swift b/Vernissage/Views/FollowRequestsView.swift index 9a0a026..7c109a6 100644 --- a/Vernissage/Views/FollowRequestsView.swift +++ b/Vernissage/Views/FollowRequestsView.swift @@ -87,12 +87,18 @@ struct FollowRequestsView: View { } } .swipeActions { - Button { + Button(role: .destructive) { + Task { + await self.approve(account: account) + } } label: { Label("followingRequests.title.approve", systemImage: "checkmark") } Button(role: .destructive) { + Task { + await self.reject(account: account) + } } label: { Label("followingRequests.title.reject", systemImage: "xmark") } @@ -156,6 +162,7 @@ struct FollowRequestsView: View { private func approve(account: Account) async { do { _ = try await self.client.followRequests?.authorizeRequest(id: account.id) + self.accounts.removeAll { $0.id == account.id } } catch { ErrorService.shared.handle(error, message: "followingRequests.error.approve", showToastr: true) } @@ -164,6 +171,7 @@ struct FollowRequestsView: View { private func reject(account: Account) async { do { _ = try await self.client.followRequests?.rejectRequest(id: account.id) + self.accounts.removeAll { $0.id == account.id } } catch { ErrorService.shared.handle(error, message: "followingRequests.error.reject", showToastr: true) }