damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit c28ab7a57cdffdf7827ad6e3268424238982b0f8
parent 09ce3af11efe4e079cf96feced06b8ba563ca444
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Fri, 21 Feb 2025 20:53:37 -0800

Renamed RelayInfo to LegacyKind3RelayRWConfiguration

This is a non-functional refactor that makes a struct name more
detailed.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>

Diffstat:
Mdamus/Models/Contacts+.swift | 8++++----
Mdamus/Models/HomeModel.swift | 4++--
Mdamus/Models/ProfileModel.swift | 2+-
Mdamus/Nostr/NostrEvent+.swift | 4++--
Mdamus/Nostr/Relay.swift | 12++++++------
Mdamus/Views/AddRelayView.swift | 2+-
6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/damus/Models/Contacts+.swift b/damus/Models/Contacts+.swift @@ -63,7 +63,7 @@ func follow_user_event(our_contacts: NostrEvent?, keypair: FullKeypair, follow: } -func decode_json_relays(_ content: String) -> [RelayURL: RelayInfo]? { +func decode_json_relays(_ content: String) -> [RelayURL: LegacyKind3RelayRWConfiguration]? { return decode_json(content) } @@ -80,7 +80,7 @@ func remove_relay(ev: NostrEvent, current_relays: [RelayDescriptor], keypair: Fu } /// Handles the creation of a new `kind:3` contact list based on a previous contact list, with the specified relays -func add_relay(ev: NostrEvent, keypair: FullKeypair, current_relays: [RelayDescriptor], relay: RelayURL, info: RelayRWConfiguration) -> NostrEvent? { +func add_relay(ev: NostrEvent, keypair: FullKeypair, current_relays: [RelayDescriptor], relay: RelayURL, info: LegacyKind3RelayRWConfiguration) -> NostrEvent? { var relays = ensure_relay_info(relays: current_relays, content: ev.content) // If kind:3 content is empty, or if the relay doesn't exist in the list, @@ -98,7 +98,7 @@ func add_relay(ev: NostrEvent, keypair: FullKeypair, current_relays: [RelayDescr return NostrEvent(content: content, keypair: keypair.to_keypair(), kind: 3, tags: ev.tags.strings()) } -func ensure_relay_info(relays: [RelayDescriptor], content: String) -> [RelayURL: RelayInfo] { +func ensure_relay_info(relays: [RelayDescriptor], content: String) -> [RelayURL: LegacyKind3RelayRWConfiguration] { return decode_json_relays(content) ?? make_contact_relays(relays) } @@ -129,7 +129,7 @@ func follow_with_existing_contacts(keypair: FullKeypair, our_contacts: NostrEven return NostrEvent(content: our_contacts.content, keypair: keypair.to_keypair(), kind: kind, tags: tags) } -func make_contact_relays(_ relays: [RelayDescriptor]) -> [RelayURL: RelayInfo] { +func make_contact_relays(_ relays: [RelayDescriptor]) -> [RelayURL: LegacyKind3RelayRWConfiguration] { return relays.reduce(into: [:]) { acc, relay in acc[relay.url] = relay.info } diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift @@ -957,12 +957,12 @@ func process_contact_event(state: DamusState, ev: NostrEvent) { } func load_our_relays(state: DamusState, m_old_ev: NostrEvent?, ev: NostrEvent) { - let bootstrap_dict: [RelayURL: RelayInfo] = [:] + let bootstrap_dict: [RelayURL: LegacyKind3RelayRWConfiguration] = [:] let old_decoded = m_old_ev.flatMap { decode_json_relays($0.content) } ?? state.bootstrap_relays.reduce(into: bootstrap_dict) { (d, r) in d[r] = .rw } - guard let decoded: [RelayURL: RelayInfo] = decode_json_relays(ev.content) else { + guard let decoded: [RelayURL: LegacyKind3RelayRWConfiguration] = decode_json_relays(ev.content) else { return } diff --git a/damus/Models/ProfileModel.swift b/damus/Models/ProfileModel.swift @@ -10,7 +10,7 @@ import Foundation class ProfileModel: ObservableObject, Equatable { @Published var contacts: NostrEvent? = nil @Published var following: Int = 0 - @Published var relays: [RelayURL: RelayInfo]? = nil + @Published var relays: [RelayURL: LegacyKind3RelayRWConfiguration]? = nil @Published var progress: Int = 0 private let MAX_SHARE_RELAYS = 4 diff --git a/damus/Nostr/NostrEvent+.swift b/damus/Nostr/NostrEvent+.swift @@ -78,8 +78,8 @@ func make_private_zap_request_event(identity: FullKeypair, enc_key: FullKeypair, func make_first_contact_event(keypair: Keypair) -> NostrEvent? { let bootstrap_relays = load_bootstrap_relays(pubkey: keypair.pubkey) - let rw_relay_info = RelayInfo(read: true, write: true) - var relays: [RelayURL: RelayInfo] = [:] + let rw_relay_info = LegacyKind3RelayRWConfiguration(read: true, write: true) + var relays: [RelayURL: LegacyKind3RelayRWConfiguration] = [:] for relay in bootstrap_relays { relays[relay] = rw_relay_info diff --git a/damus/Nostr/Relay.swift b/damus/Nostr/Relay.swift @@ -7,16 +7,16 @@ import Foundation -public struct RelayInfo: Codable { - let read: Bool? - let write: Bool? +public struct LegacyKind3RelayRWConfiguration: Codable, Sendable { + public let read: Bool? + public let write: Bool? init(read: Bool, write: Bool) { self.read = read self.write = write } - static let rw = RelayInfo(read: true, write: true) + static let rw = LegacyKind3RelayRWConfiguration(read: true, write: true) } enum RelayVariant { @@ -27,10 +27,10 @@ enum RelayVariant { public struct RelayDescriptor { let url: RelayURL - let info: RelayInfo + let info: LegacyKind3RelayRWConfiguration let variant: RelayVariant - init(url: RelayURL, info: RelayInfo, variant: RelayVariant = .regular) { + init(url: RelayURL, info: LegacyKind3RelayRWConfiguration, variant: RelayVariant = .regular) { self.url = url self.info = info self.variant = variant diff --git a/damus/Views/AddRelayView.swift b/damus/Views/AddRelayView.swift @@ -88,7 +88,7 @@ struct AddRelayView: View { return } - let info = RelayInfo.rw + let info = LegacyKind3RelayRWConfiguration.rw let descriptor = RelayDescriptor(url: url, info: info) do {