Don't show notify button in users lists

This commit is contained in:
Thomas Ricouard 2023-01-12 08:30:47 +01:00
parent 6f7c576c3a
commit c653fb79b6
3 changed files with 8 additions and 4 deletions

View File

@ -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))
}
}
}

View File

@ -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 {

View File

@ -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()