Fix crash in profile related to profile updates
Changelog-Fixed: Fix crash on profile page when there are profile updates Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -125,18 +125,22 @@ struct ProfileName: View {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile: Profile!
|
|
||||||
var profile_txn: NdbTxn<Profile?>!
|
|
||||||
|
|
||||||
switch update {
|
switch update {
|
||||||
case .remote(let pubkey):
|
case .remote(let pubkey):
|
||||||
profile_txn = damus_state.profiles.lookup(id: pubkey)
|
guard let profile_txn = damus_state.profiles.lookup(id: pubkey),
|
||||||
guard let prof = profile_txn.unsafeUnownedValue else { return }
|
let prof = profile_txn.unsafeUnownedValue else {
|
||||||
profile = prof
|
return
|
||||||
|
}
|
||||||
|
handle_profile_update(profile: prof)
|
||||||
case .manual(_, let prof):
|
case .manual(_, let prof):
|
||||||
profile = prof
|
handle_profile_update(profile: prof)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func handle_profile_update(profile: Profile) {
|
||||||
let display_name = Profile.displayName(profile: profile, pubkey: pubkey)
|
let display_name = Profile.displayName(profile: profile, pubkey: pubkey)
|
||||||
if self.display_name != display_name {
|
if self.display_name != display_name {
|
||||||
self.display_name = display_name
|
self.display_name = display_name
|
||||||
@@ -151,7 +155,6 @@ struct ProfileName: View {
|
|||||||
donation = profile.damus_donation
|
donation = profile.damus_donation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ProfileName_Previews: PreviewProvider {
|
struct ProfileName_Previews: PreviewProvider {
|
||||||
|
|||||||
Reference in New Issue
Block a user