diff --git a/damus/Nostr/CoreData/PersistedProfile.swift b/damus/Nostr/CoreData/PersistedProfile.swift index a836d2f9..4d8a037a 100644 --- a/damus/Nostr/CoreData/PersistedProfile.swift +++ b/damus/Nostr/CoreData/PersistedProfile.swift @@ -21,4 +21,16 @@ final class PersistedProfile: NSManagedObject { @NSManaged var lud16: String? @NSManaged var nip05: String? @NSManaged var last_update: Date? + + func copyValues(from profile: Profile) { + name = profile.name + display_name = profile.display_name + about = profile.about + picture = profile.picture + banner = profile.banner + website = profile.website + lud06 = profile.lud06 + lud16 = profile.lud16 + nip05 = profile.nip05 + } } diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift index bcb7d775..81077c5e 100644 --- a/damus/Nostr/Nostr.swift +++ b/damus/Nostr/Nostr.swift @@ -23,6 +23,18 @@ class Profile: Codable { self.nip05 = nip05 } + convenience init(persisted_profile: PersistedProfile) { + self.init(name: persisted_profile.name, + display_name: persisted_profile.display_name, + about: persisted_profile.about, + picture: persisted_profile.picture, + banner: persisted_profile.banner, + website: persisted_profile.website, + lud06: persisted_profile.lud06, + lud16: persisted_profile.lud16, + nip05: persisted_profile.nip05) + } + private func str(_ str: String) -> String? { return get_val(str) }