add network pull date to PersistedProfile model for staleness checking

This commit is contained in:
Bryan Montz
2023-05-15 08:29:06 -05:00
parent bc315dd571
commit 3f7b0a4d6e
3 changed files with 5 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="21G72" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="22E261" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="PersistedProfile" representedClassName="PersistedProfile" syncable="YES"> <entity name="PersistedProfile" representedClassName="PersistedProfile" syncable="YES">
<attribute name="about" optional="YES" attributeType="String"/> <attribute name="about" optional="YES" attributeType="String"/>
<attribute name="banner" optional="YES" attributeType="String"/> <attribute name="banner" optional="YES" attributeType="String"/>
@@ -9,6 +9,7 @@
<attribute name="lud06" optional="YES" attributeType="String"/> <attribute name="lud06" optional="YES" attributeType="String"/>
<attribute name="lud16" optional="YES" attributeType="String"/> <attribute name="lud16" optional="YES" attributeType="String"/>
<attribute name="name" optional="YES" attributeType="String"/> <attribute name="name" optional="YES" attributeType="String"/>
<attribute name="network_pull_date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="nip05" optional="YES" attributeType="String"/> <attribute name="nip05" optional="YES" attributeType="String"/>
<attribute name="picture" optional="YES" attributeType="String"/> <attribute name="picture" optional="YES" attributeType="String"/>
<attribute name="website" optional="YES" attributeType="String"/> <attribute name="website" optional="YES" attributeType="String"/>

View File

@@ -20,7 +20,8 @@ final class PersistedProfile: NSManagedObject {
@NSManaged var lud06: String? @NSManaged var lud06: String?
@NSManaged var lud16: String? @NSManaged var lud16: String?
@NSManaged var nip05: 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) { func copyValues(from profile: Profile) {
name = profile.name name = profile.name

View File

@@ -99,6 +99,7 @@ final class ProfileDatabase {
} }
persisted_profile?.copyValues(from: profile) persisted_profile?.copyValues(from: profile)
persisted_profile?.last_update = last_update persisted_profile?.last_update = last_update
persisted_profile?.network_pull_date = Date.now
try context.save() try context.save()
} }