profile: don't auto-load followers

This is a bandwidth-intensive operation

Changelog-Changed: Don't auto-load follower count
This commit is contained in:
William Casarin
2022-12-23 15:17:19 -08:00
parent 85ba7bbed0
commit acb2049641
3 changed files with 33 additions and 13 deletions

View File

@@ -201,20 +201,33 @@ struct ProfileView: View {
}
let fview = FollowersView(damus_state: damus_state, whos: profile.pubkey)
.environmentObject(followers)
NavigationLink(destination: fview) {
HStack {
Text("\(followers.contacts.count)")
.font(.subheadline.weight(.medium))
Text("Followers")
.font(.subheadline)
.foregroundColor(.gray)
if followers.contacts != nil {
NavigationLink(destination: fview) {
FollowersCount
}
.buttonStyle(PlainButtonStyle())
} else {
FollowersCount
.onTapGesture {
UIImpactFeedbackGenerator(style: .light).impactOccurred()
followers.contacts = []
followers.subscribe()
}
}
.buttonStyle(PlainButtonStyle())
}
}
}
var FollowersCount: some View {
HStack {
Text("\(followers.count_display)")
.font(.subheadline.weight(.medium))
Text("Followers")
.font(.subheadline)
.foregroundColor(.gray)
}
}
var body: some View {
VStack(alignment: .leading) {
ScrollView {
@@ -237,7 +250,7 @@ struct ProfileView: View {
}
.onDisappear {
profile.unsubscribe()
//followers.unsubscribe()
followers.unsubscribe()
// our profilemodel needs a bit more help
}
}