Fix tag follow button

This commit is contained in:
Thomas Ricouard 2024-01-05 21:28:46 +01:00
parent ef204cf6fd
commit f401d4094d
3 changed files with 10 additions and 3 deletions

View File

@ -16,7 +16,8 @@ public struct Tag: Codable, Identifiable, Equatable, Hashable {
}
public static func == (lhs: Tag, rhs: Tag) -> Bool {
lhs.name == rhs.name
lhs.name == rhs.name &&
lhs.following == rhs.following
}
public var id: String {

View File

@ -144,7 +144,7 @@ public struct StatusRowView: View {
#endif
.listRowInsets(.init(top: 12,
leading: .layoutPadding,
bottom: 12,
bottom: 6,
trailing: .layoutPadding))
.accessibilityElement(children: isFocused ? .contain : .combine)
.accessibilityLabel(isFocused == false && accessibilityVoiceOverEnabled

View File

@ -8,6 +8,8 @@ struct TimelineTagHeaderView: View {
@Binding var tag: Tag?
@State var isLoading: Bool = false
var body: some View {
if let tag {
TimelineHeaderView {
@ -26,15 +28,19 @@ struct TimelineTagHeaderView: View {
Spacer()
Button {
Task {
isLoading = true
if tag.following {
self.tag = await account.unfollowTag(id: tag.name)
} else {
self.tag = await account.followTag(id: tag.name)
}
isLoading = false
}
} label: {
Text(tag.following ? "account.follow.following" : "account.follow.follow")
}.buttonStyle(.bordered)
}
.disabled(isLoading)
.buttonStyle(.bordered)
}
}
}