From c653fb79b649a177c5b70a55734e86f3e45d0740 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Thu, 12 Jan 2023 08:30:47 +0100 Subject: [PATCH] Don't show notify button in users lists --- .../Account/Sources/Account/AccountDetailHeaderView.swift | 3 ++- .../Sources/Account/AccountsLIst/AccountsListRow.swift | 3 ++- Packages/Account/Sources/Account/Follow/FollowButton.swift | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Packages/Account/Sources/Account/AccountDetailHeaderView.swift b/Packages/Account/Sources/Account/AccountDetailHeaderView.swift index 01dbf037..91b778a8 100644 --- a/Packages/Account/Sources/Account/AccountDetailHeaderView.swift +++ b/Packages/Account/Sources/Account/AccountDetailHeaderView.swift @@ -118,7 +118,8 @@ struct AccountDetailHeaderView: View { if let relationship = viewModel.relationship, !viewModel.isCurrentUser { HStack { FollowButton(viewModel: .init(accountId: account.id, - relationship: relationship)) + relationship: relationship, + shouldDisplayNotify: true)) } } } diff --git a/Packages/Account/Sources/Account/AccountsLIst/AccountsListRow.swift b/Packages/Account/Sources/Account/AccountsLIst/AccountsListRow.swift index 80ecc963..15031ce8 100644 --- a/Packages/Account/Sources/Account/AccountsLIst/AccountsListRow.swift +++ b/Packages/Account/Sources/Account/AccountsLIst/AccountsListRow.swift @@ -49,7 +49,8 @@ public struct AccountsListRow: View { Spacer() if currentAccount.account?.id != viewModel.account.id { FollowButton(viewModel: .init(accountId: viewModel.account.id, - relationship: viewModel.relationShip)) + relationship: viewModel.relationShip, + shouldDisplayNotify: false)) } } .onAppear { diff --git a/Packages/Account/Sources/Account/Follow/FollowButton.swift b/Packages/Account/Sources/Account/Follow/FollowButton.swift index 05013488..cdae31b3 100644 --- a/Packages/Account/Sources/Account/Follow/FollowButton.swift +++ b/Packages/Account/Sources/Account/Follow/FollowButton.swift @@ -8,12 +8,14 @@ public class FollowButtonViewModel: ObservableObject { var client: Client? public let accountId: String + public let shouldDisplayNotify: Bool @Published private(set) public var relationship: Relationshionship @Published private(set) public var isUpdating: Bool = false - public init(accountId: String, relationship: Relationshionship) { + public init(accountId: String, relationship: Relationshionship, shouldDisplayNotify: Bool) { self.accountId = accountId self.relationship = relationship + self.shouldDisplayNotify = shouldDisplayNotify } func follow() async { @@ -75,7 +77,7 @@ public struct FollowButton: View { } .buttonStyle(.bordered) .disabled(viewModel.isUpdating) - if viewModel.relationship.following { + if viewModel.relationship.following, viewModel.shouldDisplayNotify { Button { Task { await viewModel.toggleNotify()