performance: don't spam nip05 validation on startup
Since we don't show these on events anymore, we don't need to spam nip05 validation. We can just check when we go to the profile page Changelog-Fixed: Eliminate nostr address validation bandwidth on startup
This commit is contained in:
@@ -457,6 +457,7 @@ struct ProfileView: View {
|
||||
dismiss()
|
||||
}
|
||||
.onAppear() {
|
||||
check_nip05_validity(pubkey: self.profile.pubkey, profiles: self.damus_state.profiles)
|
||||
profile.subscribe()
|
||||
//followers.subscribe()
|
||||
}
|
||||
@@ -565,3 +566,25 @@ extension View {
|
||||
.foregroundStyle(scheme == .dark ? .white : .black, scheme == .dark ? .white : .black)
|
||||
}
|
||||
}
|
||||
|
||||
func check_nip05_validity(pubkey: String, profiles: Profiles) {
|
||||
guard let profile = profiles.lookup(id: pubkey),
|
||||
let nip05 = profile.nip05,
|
||||
profiles.is_validated(pubkey) == nil
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
||||
Task.detached(priority: .background) {
|
||||
let validated = await validate_nip05(pubkey: pubkey, nip05_str: nip05)
|
||||
if validated != nil {
|
||||
print("validated nip05 for '\(nip05)'")
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
profiles.set_validated(pubkey, nip05: validated)
|
||||
profiles.nip05_pubkey[nip05] = pubkey
|
||||
notify(.profile_updated, ProfileUpdate(pubkey: pubkey, profile: profile))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user