Fix a few more hitches

This commit is contained in:
William Casarin
2023-04-12 18:22:16 -07:00
parent e9f71ed07c
commit 54c8958250
3 changed files with 51 additions and 46 deletions

View File

@@ -651,10 +651,12 @@ func print_filters(relay_id: String?, filters groups: [[NostrFilter]]) {
} }
func process_metadata_event(our_pubkey: String, profiles: Profiles, ev: NostrEvent) { func process_metadata_event(our_pubkey: String, profiles: Profiles, ev: NostrEvent) {
DispatchQueue.global(qos: .background).async {
guard let profile: Profile = decode_data(Data(ev.content.utf8)) else { guard let profile: Profile = decode_data(Data(ev.content.utf8)) else {
return return
} }
DispatchQueue.main.async {
if our_pubkey == ev.pubkey && (profile.deleted ?? false) { if our_pubkey == ev.pubkey && (profile.deleted ?? false) {
DispatchQueue.main.async { DispatchQueue.main.async {
notify(.deleted_account, ()) notify(.deleted_account, ())
@@ -705,6 +707,9 @@ func process_metadata_event(our_pubkey: String, profiles: Profiles, ev: NostrEve
} }
notify(.profile_updated, ProfileUpdate(pubkey: ev.pubkey, profile: profile)) notify(.profile_updated, ProfileUpdate(pubkey: ev.pubkey, profile: profile))
}
}
} }
func robohash(_ pk: String) -> String { func robohash(_ pk: String) -> String {

View File

@@ -82,7 +82,7 @@ class NostrEvent: Codable, Identifiable, CustomStringConvertible, Equatable, Has
} }
var too_big: Bool { var too_big: Bool {
return self.content.count > 16000 return self.content.underestimatedCount > 16000
} }
var should_show_event: Bool { var should_show_event: Bool {

View File

@@ -89,7 +89,7 @@ final class RelayConnection: WebSocketDelegate {
self.isConnected = false self.isConnected = false
case .text(let txt): case .text(let txt):
if txt.count > 2000 { if txt.underestimatedCount > 2000 {
DispatchQueue.global(qos: .default).async { DispatchQueue.global(qos: .default).async {
if let ev = decode_nostr_event(txt: txt) { if let ev = decode_nostr_event(txt: txt) {
DispatchQueue.main.async { DispatchQueue.main.async {