Browse Source

new account fixes

Signed-off-by: William Casarin <jb55@jb55.com>
profiles-everywhere
William Casarin 3 years ago
parent
commit
6bca9eb2be
  1. 2
      damus/Models/FollowersModel.swift
  2. 2
      damus/Models/FollowingModel.swift
  3. 11
      damus/Models/HomeModel.swift
  4. 23
      damus/Models/ProfileModel.swift
  5. 2
      damus/Models/SearchHomeModel.swift
  6. 3
      damus/Models/SearchModel.swift
  7. 4
      damus/Nostr/NostrResponse.swift
  8. 6
      damus/Views/ProfilePictureSelector.swift
  9. 2
      damus/Views/SaveKeysView.swift

2
damus/Models/FollowersModel.swift

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

2
damus/Models/FollowingModel.swift

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

11
damus/Models/HomeModel.swift

@ -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
}

23
damus/Models/ProfileModel.swift

@ -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]
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
}
}
}

2
damus/Models/SearchHomeModel.swift

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

3
damus/Models/SearchModel.swift

@ -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
}
}
}

4
damus/Nostr/NostrResponse.swift

@ -10,6 +10,7 @@ import Foundation
enum NostrResponse: Decodable {
case event(String, NostrEvent)
case notice(String)
case eose
init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
@ -32,6 +33,9 @@ enum NostrResponse: Decodable {
let msg = try container.decode(String.self)
self = .notice(msg)
return
} else if typ == "EOSE" {
self = .eose
return
}
throw DecodingError.dataCorrupted(.init(codingPath: [], debugDescription: "expected EVENT or NOTICE, got \(typ)"))

6
damus/Views/ProfilePictureSelector.swift

@ -13,11 +13,13 @@ struct ProfilePictureSelector: View {
var body: some View {
let highlight: Highlight = .custom(Color.white, 2.0)
ZStack {
ProfilePicView(pubkey: pubkey, size: 80.0, highlight: highlight, image_cache: ImageCache(), profiles: Profiles())
/*
Image(systemName: "camera")
.font(.title)
.foregroundColor(.white)
*/
ProfilePicView(pubkey: pubkey, size: 80.0, highlight: highlight, image_cache: ImageCache(), profiles: Profiles())
}
}
}

2
damus/Views/SaveKeysView.swift

@ -121,6 +121,8 @@ struct SaveKeysView: View {
print(msg)
case .event:
print("event in signup?")
case .eose:
break
}
}
}

Loading…
Cancel
Save