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:
@@ -83,7 +83,7 @@ struct DamusPurpleAccountView: View {
|
||||
|
||||
SupporterBadge(
|
||||
percent: nil,
|
||||
purple_badge_info: DamusPurple.UserBadgeInfo.from(account: account),
|
||||
purple_account: account,
|
||||
style: .full
|
||||
)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ struct DamusPurpleNewUserOnboardingView: View {
|
||||
.ignoresSafeArea() // Necessary to avoid weird white edges
|
||||
}
|
||||
.task {
|
||||
guard let account = try? await damus_state.purple.get_account(pubkey: damus_state.pubkey), account.active else {
|
||||
guard let account = try? await damus_state.purple.fetch_account(pubkey: damus_state.pubkey), account.active else {
|
||||
return
|
||||
}
|
||||
// Let's notify other views across SwiftUI to update our user's Purple status.
|
||||
|
||||
@@ -117,7 +117,7 @@ struct DamusPurpleView: View {
|
||||
|
||||
func load_account() async {
|
||||
do {
|
||||
if let account = try await damus_state.purple.get_account(pubkey: damus_state.keypair.pubkey) {
|
||||
if let account = try await damus_state.purple.fetch_account(pubkey: damus_state.keypair.pubkey) {
|
||||
self.my_account_info_state = .loaded(account: account)
|
||||
return
|
||||
}
|
||||
@@ -232,7 +232,8 @@ struct DamusPurpleView: View {
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
self.damus_state.purple.starred_profiles_cache[keypair.pubkey] = nil
|
||||
// TODO (will): why do this here?
|
||||
//self.damus_state.purple.starred_profiles_cache[keypair.pubkey] = nil
|
||||
Task {
|
||||
await self.damus_state.purple.send_receipt()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user