Fix sync failing with feeds lacking title
This commit is contained in:
parent
749e109165
commit
ef215e8bdc
|
@ -9,7 +9,7 @@ import Foundation
|
||||||
|
|
||||||
public struct Feed: Decodable, Sendable {
|
public struct Feed: Decodable, Sendable {
|
||||||
public let id: FervorID
|
public let id: FervorID
|
||||||
public let title: String
|
public let title: String?
|
||||||
public let url: URL?
|
public let url: URL?
|
||||||
public let serviceURL: URL?
|
public let serviceURL: URL?
|
||||||
public let feedURL: URL
|
public let feedURL: URL
|
||||||
|
@ -20,7 +20,7 @@ public struct Feed: Decodable, Sendable {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
self.id = try container.decode(FervorID.self, forKey: .id)
|
self.id = try container.decode(FervorID.self, forKey: .id)
|
||||||
self.title = try container.decode(String.self, forKey: .title)
|
self.title = try container.decodeIfPresent(String.self, forKey: .title)
|
||||||
self.url = try container.decode(URL?.self, forKey: .url)
|
self.url = try container.decode(URL?.self, forKey: .url)
|
||||||
self.serviceURL = try container.decodeIfPresent(URL.self, forKey: .serviceURL)
|
self.serviceURL = try container.decodeIfPresent(URL.self, forKey: .serviceURL)
|
||||||
self.feedURL = try container.decode(URL.self, forKey: .feedURL)
|
self.feedURL = try container.decode(URL.self, forKey: .feedURL)
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>_XCCurrentVersionName</key>
|
<key>_XCCurrentVersionName</key>
|
||||||
<string>Reader 3.xcdatamodel</string>
|
<string>Reader 4.xcdatamodel</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22222" systemVersion="22G91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||||
|
<entity name="Feed" representedClassName="Feed" syncable="YES">
|
||||||
|
<attribute name="id" attributeType="String"/>
|
||||||
|
<attribute name="lastUpdated" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
<attribute name="title" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="url" optional="YES" attributeType="URI"/>
|
||||||
|
<relationship name="groups" toMany="YES" deletionRule="Nullify" destinationEntity="Group" inverseName="feeds" inverseEntity="Group"/>
|
||||||
|
<relationship name="items" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Item" inverseName="feed" inverseEntity="Item"/>
|
||||||
|
</entity>
|
||||||
|
<entity name="Group" representedClassName="Group" syncable="YES">
|
||||||
|
<attribute name="id" attributeType="String"/>
|
||||||
|
<attribute name="title" attributeType="String"/>
|
||||||
|
<relationship name="feeds" toMany="YES" deletionRule="Nullify" destinationEntity="Feed" inverseName="groups" inverseEntity="Feed"/>
|
||||||
|
</entity>
|
||||||
|
<entity name="Item" representedClassName="Item" versionHashModifier="5" syncable="YES">
|
||||||
|
<attribute name="author" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="content" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="excerpt" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="generatedExcerpt" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="id" attributeType="String"/>
|
||||||
|
<attribute name="needsReadStateSync" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="published" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
<attribute name="read" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="title" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="url" optional="YES" attributeType="URI"/>
|
||||||
|
<relationship name="feed" maxCount="1" deletionRule="Nullify" destinationEntity="Feed" inverseName="items" inverseEntity="Feed"/>
|
||||||
|
<fetchIndex name="byID">
|
||||||
|
<fetchIndexElement property="id" type="Binary" order="ascending"/>
|
||||||
|
</fetchIndex>
|
||||||
|
<fetchIndex name="byRead">
|
||||||
|
<fetchIndexElement property="read" type="Binary" order="ascending"/>
|
||||||
|
</fetchIndex>
|
||||||
|
</entity>
|
||||||
|
<entity name="SyncState" representedClassName="SyncState" syncable="YES" codeGenerationType="class">
|
||||||
|
<attribute name="lastSync" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
</entity>
|
||||||
|
<fetchRequest name="FetchRequest" entity="Item" predicateString="TRUEPREDICATE"/>
|
||||||
|
</model>
|
|
@ -74,8 +74,8 @@ actor FervorController {
|
||||||
setSyncState(.groupsAndFeeds)
|
setSyncState(.groupsAndFeeds)
|
||||||
|
|
||||||
logger.info("Syncing groups and feeds")
|
logger.info("Syncing groups and feeds")
|
||||||
async let groups = try client.groups()
|
let groups = try await client.groups()
|
||||||
async let feeds = try client.feeds()
|
let feeds = try await client.feeds()
|
||||||
try await persistentContainer.sync(serverGroups: groups, serverFeeds: feeds)
|
try await persistentContainer.sync(serverGroups: groups, serverFeeds: feeds)
|
||||||
|
|
||||||
setSyncState(.items)
|
setSyncState(.items)
|
||||||
|
|
|
@ -24,7 +24,7 @@ enum ItemListType: Hashable, Equatable {
|
||||||
case let .group(group):
|
case let .group(group):
|
||||||
return group.title
|
return group.title
|
||||||
case let .feed(feed):
|
case let .feed(feed):
|
||||||
return feed.title!
|
return feed.title ?? feed.url?.host() ?? "Unknown Feed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue