new account fixes

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-06-08 13:49:04 -07:00
parent 23bb7c7f18
commit 6bca9eb2be
9 changed files with 45 additions and 12 deletions

View File

@@ -64,6 +64,8 @@ class FollowersModel: ObservableObject {
}
case .notice(let msg):
print("followingmodel notice: \(msg)")
case .eose:
break
}
}
}

View File

@@ -64,6 +64,8 @@ class FollowingModel {
}
case .notice(let msg):
print("followingmodel notice: \(msg)")
case .eose:
break
}
}
}

View File

@@ -176,6 +176,9 @@ class HomeModel: ObservableObject {
case .notice(let msg):
//self.events.insert(NostrEvent(content: "NOTICE from \(relay_id): \(msg)", pubkey: "system"), at: 0)
print(msg)
case .eose:
break
}
}
}
@@ -395,11 +398,15 @@ func process_metadata_event(profiles: Profiles, ev: NostrEvent) {
func process_contact_event(pool: RelayPool, contacts: Contacts, pubkey: String, ev: NostrEvent) {
load_our_contacts(contacts: contacts, our_pubkey: pubkey, ev: ev)
load_our_relays(pool: pool, ev: ev)
load_our_relays(our_pubkey: pubkey, pool: pool, ev: ev)
add_contact_if_friend(contacts: contacts, ev: ev)
}
func load_our_relays(pool: RelayPool, ev: NostrEvent) {
func load_our_relays(our_pubkey: String, pool: RelayPool, ev: NostrEvent) {
guard ev.pubkey == our_pubkey else {
return
}
guard let decoded = decode_json_relays(ev.content) else {
return
}

View File

@@ -17,6 +17,7 @@ class ProfileModel: ObservableObject {
var seen_event: Set<String> = Set()
var sub_id = UUID().description
var prof_subid = UUID().description
func get_follow_target() -> FollowTarget {
if let contacts = contacts {
@@ -33,24 +34,30 @@ class ProfileModel: ObservableObject {
func unsubscribe() {
print("unsubscribing from profile \(pubkey) with sub_id \(sub_id)")
damus.pool.unsubscribe(sub_id: sub_id)
damus.pool.unsubscribe(sub_id: prof_subid)
}
func subscribe() {
var text_filter = NostrFilter.filter_kinds([
NostrKind.text.rawValue
])
var profile_filter = NostrFilter.filter_kinds([
NostrKind.text.rawValue,
NostrKind.boost.rawValue,
NostrKind.metadata.rawValue,
NostrKind.contacts.rawValue,
NostrKind.metadata.rawValue,
NostrKind.boost.rawValue,
NostrKind.like.rawValue
])
profile_filter.authors = [pubkey]
profile_filter.limit = 1000
let filters = [profile_filter]
profile_filter.authors = [pubkey]
text_filter.authors = [pubkey]
text_filter.limit = 1000
print("subscribing to profile \(pubkey) with sub_id \(sub_id)")
print_filters(relay_id: "profile", filters: [filters])
damus.pool.subscribe(sub_id: sub_id, filters: filters, handler: handle_event)
print_filters(relay_id: "profile", filters: [[text_filter], [profile_filter]])
damus.pool.subscribe(sub_id: sub_id, filters: [text_filter], handler: handle_event)
damus.pool.subscribe(sub_id: prof_subid, filters: [profile_filter], handler: handle_event)
}
func handle_profile_contact_event(_ ev: NostrEvent) {
@@ -86,6 +93,8 @@ class ProfileModel: ObservableObject {
add_event(ev)
case .notice(let notice):
notify(.notice, notice)
case .eose:
break
}
}
}

View File

@@ -51,6 +51,8 @@ class SearchHomeModel: ObservableObject {
}
case .notice(let msg):
print("search home notice: \(msg)")
case .eose:
break
}
}
}

View File

@@ -91,6 +91,9 @@ func handle_subid_event(pool: RelayPool, sub_id: String, relay_id: String, ev: N
pool.reconnect(to: [relay_id])
}
break
case .eose:
break
}
}
}