purple: consolidate UserBadgeInfo with Account
Rename get_account to fetch_account to make it clear that it is always a call to the server. Add get_maybe_cached_account method that checks cached before calling fetch_account. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -41,14 +41,14 @@ struct ProfileName: View {
|
||||
@State var display_name: DisplayName?
|
||||
@State var nip05: NIP05?
|
||||
@State var donation: Int?
|
||||
@State var purple_badge: DamusPurple.UserBadgeInfo?
|
||||
|
||||
@State var purple_account: DamusPurple.Account?
|
||||
|
||||
init(pubkey: Pubkey, prefix: String = "", damus: DamusState, show_nip5_domain: Bool = true) {
|
||||
self.pubkey = pubkey
|
||||
self.prefix = prefix
|
||||
self.damus_state = damus
|
||||
self.show_nip5_domain = show_nip5_domain
|
||||
self.purple_badge = nil
|
||||
self.purple_account = nil
|
||||
}
|
||||
|
||||
var friend_type: FriendType? {
|
||||
@@ -109,15 +109,15 @@ struct ProfileName: View {
|
||||
.frame(width: 14, height: 14)
|
||||
}
|
||||
|
||||
SupporterBadge(percent: supporter(profile: profile), purple_badge_info: self.purple_badge, style: .full)
|
||||
SupporterBadge(percent: supporter(profile: profile), purple_account: self.purple_account, style: .compact)
|
||||
|
||||
|
||||
}
|
||||
.onAppear(perform: {
|
||||
Task {
|
||||
if damus_state.purple.enable_purple {
|
||||
self.purple_badge = await damus_state.purple.profile_purple_badge_info(pubkey: pubkey)
|
||||
}
|
||||
.task {
|
||||
if damus_state.purple.enable_purple {
|
||||
self.purple_account = try? await damus_state.purple.get_maybe_cached_account(pubkey: pubkey)
|
||||
}
|
||||
})
|
||||
}
|
||||
.onReceive(handle_notify(.profile_updated)) { update in
|
||||
if update.pubkey != pubkey {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user