From 3f7b0a4d6e1aeabad45aa64d4aba619e374e9ccd Mon Sep 17 00:00:00 2001 From: Bryan Montz Date: Mon, 15 May 2023 08:29:06 -0500 Subject: [PATCH] add network pull date to PersistedProfile model for staleness checking --- .../CoreData/Damus.xcdatamodeld/Damus.xcdatamodel/contents | 3 ++- damus/Nostr/CoreData/PersistedProfile.swift | 3 ++- damus/Nostr/ProfileDatabase.swift | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/damus/Nostr/CoreData/Damus.xcdatamodeld/Damus.xcdatamodel/contents b/damus/Nostr/CoreData/Damus.xcdatamodeld/Damus.xcdatamodel/contents index 57a6fe21..0f985f18 100644 --- a/damus/Nostr/CoreData/Damus.xcdatamodeld/Damus.xcdatamodel/contents +++ b/damus/Nostr/CoreData/Damus.xcdatamodeld/Damus.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -9,6 +9,7 @@ + diff --git a/damus/Nostr/CoreData/PersistedProfile.swift b/damus/Nostr/CoreData/PersistedProfile.swift index 4d8a037a..6a1b0790 100644 --- a/damus/Nostr/CoreData/PersistedProfile.swift +++ b/damus/Nostr/CoreData/PersistedProfile.swift @@ -20,7 +20,8 @@ final class PersistedProfile: NSManagedObject { @NSManaged var lud06: String? @NSManaged var lud16: String? @NSManaged var nip05: String? - @NSManaged var last_update: Date? + @NSManaged var last_update: Date? // The date that the profile was last updated by the user + @NSManaged var network_pull_date: Date? // The date we got this profile from a relay (for staleness checking) func copyValues(from profile: Profile) { name = profile.name diff --git a/damus/Nostr/ProfileDatabase.swift b/damus/Nostr/ProfileDatabase.swift index 66df42f8..c16491a1 100644 --- a/damus/Nostr/ProfileDatabase.swift +++ b/damus/Nostr/ProfileDatabase.swift @@ -99,6 +99,7 @@ final class ProfileDatabase { } persisted_profile?.copyValues(from: profile) persisted_profile?.last_update = last_update + persisted_profile?.network_pull_date = Date.now try context.save() }