Store local only post data

This commit is contained in:
Shadowfacts 2022-01-23 10:57:32 -05:00
parent 2198e2bf3e
commit 51cb7c3edf
3 changed files with 10 additions and 3 deletions

View File

@ -38,6 +38,9 @@ public final class Status: /*StatusProtocol,*/ Decodable {
public let bookmarked: Bool? public let bookmarked: Bool?
public let card: Card? public let card: Card?
public let poll: Poll? public let poll: Poll?
// Hometown only
// TODO: glitch too?
public let localOnly: Bool?
public var applicationName: String? { application?.name } public var applicationName: String? { application?.name }
@ -134,6 +137,7 @@ public final class Status: /*StatusProtocol,*/ Decodable {
case bookmarked case bookmarked
case card case card
case poll case poll
case localOnly = "local_only"
} }
} }

View File

@ -45,6 +45,7 @@ public final class StatusMO: NSManagedObject, StatusProtocol {
@NSManaged private var pollData: Data? @NSManaged private var pollData: Data?
@NSManaged public var account: AccountMO @NSManaged public var account: AccountMO
@NSManaged public var reblog: StatusMO? @NSManaged public var reblog: StatusMO?
@NSManaged public var localOnly: Bool
@LazilyDecoding(arrayFrom: \StatusMO.attachmentsData) @LazilyDecoding(arrayFrom: \StatusMO.attachmentsData)
public var attachments: [Attachment] public var attachments: [Attachment]
@ -134,6 +135,7 @@ extension StatusMO {
self.url = status.url self.url = status.url
self.visibility = status.visibility self.visibility = status.visibility
self.poll = status.poll self.poll = status.poll
self.localOnly = status.localOnly ?? false
if let existing = container.account(for: status.account.id, in: context) { if let existing = container.account(for: status.account.id, in: context) {
existing.updateFrom(apiAccount: status.account, container: container) existing.updateFrom(apiAccount: status.account, container: container)

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="18154" systemVersion="20D91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19574" systemVersion="21C52" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Account" representedClassName="AccountMO" syncable="YES"> <entity name="Account" representedClassName="AccountMO" syncable="YES">
<attribute name="acct" attributeType="String"/> <attribute name="acct" attributeType="String"/>
<attribute name="avatar" attributeType="URI"/> <attribute name="avatar" attributeType="URI"/>
@ -43,7 +43,7 @@
<entity name="Status" representedClassName="StatusMO" syncable="YES"> <entity name="Status" representedClassName="StatusMO" syncable="YES">
<attribute name="applicationName" optional="YES" attributeType="String"/> <attribute name="applicationName" optional="YES" attributeType="String"/>
<attribute name="attachmentsData" attributeType="Binary"/> <attribute name="attachmentsData" attributeType="Binary"/>
<attribute name="bookmarkedInternal" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/> <attribute name="bookmarkedInternal" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="cardData" optional="YES" attributeType="Binary"/> <attribute name="cardData" optional="YES" attributeType="Binary"/>
<attribute name="content" attributeType="String"/> <attribute name="content" attributeType="String"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
@ -54,6 +54,7 @@
<attribute name="id" attributeType="String"/> <attribute name="id" attributeType="String"/>
<attribute name="inReplyToAccountID" optional="YES" attributeType="String"/> <attribute name="inReplyToAccountID" optional="YES" attributeType="String"/>
<attribute name="inReplyToID" optional="YES" attributeType="String"/> <attribute name="inReplyToID" optional="YES" attributeType="String"/>
<attribute name="localOnly" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="mentionsData" attributeType="Binary"/> <attribute name="mentionsData" attributeType="Binary"/>
<attribute name="muted" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/> <attribute name="muted" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="pinnedInternal" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/> <attribute name="pinnedInternal" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
@ -77,6 +78,6 @@
<elements> <elements>
<element name="Account" positionX="169.21875" positionY="78.9609375" width="128" height="329"/> <element name="Account" positionX="169.21875" positionY="78.9609375" width="128" height="329"/>
<element name="Relationship" positionX="63" positionY="135" width="128" height="208"/> <element name="Relationship" positionX="63" positionY="135" width="128" height="208"/>
<element name="Status" positionX="-63" positionY="-18" width="128" height="434"/> <element name="Status" positionX="-63" positionY="-18" width="128" height="449"/>
</elements> </elements>
</model> </model>